function validation(reg) {
str = document.reg;
if (str.name.value == "") {
alert("Enter your name");
str.name.focus();
return false;
}
Validation will working fine if input is empty.
Problem
How to prevent it?
Here are some trim functions.
http://www.somacon.com/p355.php
and using it
function validation(reg) {
str = document.reg;
if (str.name.value.trim() == "") {
alert("Enter your name");
str.name.focus();
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With