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
- User can enter a blank space on the first.
- Also user can enter space only on the name.
How to prevent it?