0

Hi,I am trying to verify form input for length(before that I would like to trim it)
How can I do that for user
Thanks

function verify(){
var user=document.getElementById("user");
var pass=document.getElementById("pass");
var msg= "";
document.write("Length "+user.length);
if(user.value == ""){
  msg+= "Please enter a username!\n";
  user.className = "inpBoxError";
  }
if(pass.value == ""){
  msg+= "Please enter a password!\n";
  pass.className = "inpBoxError";
  }
  if(msg == ""){
  return true;
  }
  else
  {
  alert(msg);
  return false;
  }
 }
</script>
<table border="0">
<form action="index.htm" method="post" onSubmit="return verify();">
<tr colspan="2" allign="center"><td> Form Name</td></tr>
<tr><td>User</td>
<td><input type="text" name="user" id="user" class="inpBox"></td></tr>
<tr><td>Pass</td>
<td><input type="password" name="pass" id="pass" class="inpBox"></td></tr>
<tr><td colspan="2"  align="center">
<input type="submit" value="Enter" name="submit"></td></tr>
</form>
</table>
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by HG&C
0

line 5: user.value.length
will give you the length of the string in the text box, though you've probably figured this out by now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.