I have a form with three fields Name, Email Address & Password. now i want to prevent the user to enter space " " at the start of value,let say user could not enter only spaces in the fields.
I tried to fix it like this:
<script type="text/javascript">
function validate(){
if ((document.getElementById('fName').value) == '') {
alert('Please enter your first name');
return (false);
} else if ((document.getElementById('lName').value) == '') {
alert('Please enter your last name');
return (false);
} else {
return (true);
}
}
</script>
<form name="form1" id="form1" action="index.php" method="post">
<table align="right" border="0">
<tr>
<td>First Name:</td>
<td><input id="fName" name="fName" type="text" class="input-login"/></td>
</tr>
<tr><td>Email Address:</td></tr>
<tr><td><input id="email" name="email" type="text" class="input-login"/></td></tr>
<tr><td>Password:</td></tr>
<tr><td><input id="password" name="password" type="password" class="input-login"/>/td></tr>
<tr><td align="center"><a href="#">Forgot password</a></td></tr>
<tr>
<td align="center"><input name="login" id="login" type="submit" value="Login" >
<input name="signup" id="signup" type="submit" value="SignUp" ></td>
</tr>
</table>
</form>
but fail to fix.
can anyone help me.. Thanks.