Hi,
I'm trying to do some simple form validation on an ASP page, but after trying for a couple of hours, it still doens't work.
This is the javascript function I have. When I pass a form as the checkForm variable, I do get alert boxes coming up, but they say 'undefined' instead of what I have.
<Script language="Javascript">
function Validate(checkForm) {
if (checkForm.Username.Value == "") {
alert('No User Name!');
return false;
} else {
alert(checkForm.UserName.Value);
}
return true;
}
</Script>
This is the HTML form; its wrapped in a number of divisions from CSS.
<FORM NAME="UserForm" Method="Post" Action="test.asp">
UserName:
<INPUT TYPE="text" Name="UserName"><BR>
<INPUT TYPE="button" Name="Add" Value="Add" onClick="Validate(document.UserForm)">
</FORM>
Any tips would be greatly appreciated; this problem has driven me mad; since its supposed to be so simple!
Thanks.
I'm trying to do some simple form validation on an ASP page, but after trying for a couple of hours, it still doens't work.
This is the javascript function I have. When I pass a form as the checkForm variable, I do get alert boxes coming up, but they say 'undefined' instead of what I have.
<Script language="Javascript">
function Validate(checkForm) {
if (checkForm.Username.Value == "") {
alert('No User Name!');
return false;
} else {
alert(checkForm.UserName.Value);
}
return true;
}
</Script>
This is the HTML form; its wrapped in a number of divisions from CSS.
<FORM NAME="UserForm" Method="Post" Action="test.asp">
UserName:
<INPUT TYPE="text" Name="UserName"><BR>
<INPUT TYPE="button" Name="Add" Value="Add" onClick="Validate(document.UserForm)">
</FORM>
Any tips would be greatly appreciated; this problem has driven me mad; since its supposed to be so simple!
Thanks.