|
Hi,
I have this form in asp. It works, except that the form validation does not seem to work. It is intended to do server-side form validation. I cann't figure out what is wrong. The file is an asp file. The validation function is in JavaScript. Here is the code:
html>
<head>
<title>Form</title>
<script language="JavaScript" type="text/javascript">
<!--
function validate(form){
if (form.FName.value == ""){
alert("You must enter a First Name.");
form.FName.focus();
return false;
}
if (form.LName == ""){
alert("You must enter a Last Name.");
form.LName.focus();
return false;
}
if (form.City == ""){
alert("You must enter a City.");
form.City.focus();
return false;
}
if (form.Country == ""){
alert("You must enter a Country.");
form.Country.focus();
return false;
}
if (form.SecretWord == ""){
alert("You must enter a Country.");
form.SecretWord.focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body bgcolor="white" text="black">
<!-- Begin form code -->
<form name=form action=updatedatabase.asp method=post onsubmit="javascript:return validate(this)">
<input type="submit" name="submit" value="submit">
<br>
<i> Please, use the following format in entering your Mobile Number </i>
<br>
<i>(+CountryCode)AreaCode-999-9999</i>
<br>
<i><b>Example:</b></i>
<br>
<i>(+971)50-763-4167<i/>
<br>
<br>
<TABLE border="1">
<CAPTION><b>Subscribtion Service</b></CAPTION>
<TR><TH>First Name:</TH><TD>
<input type="text" name="FName" maxlength="20" size="20"></TD></TR>
<TR><TH>Last Name:</TH><TD>
<input type="text" name="LName" maxlength="20" size="20"></TD></TR>
<TR><TH>Mobile Number:</TH><TD>
<input type="text" name="MobilePhone" maxlength="20" size="20"></TD></TR>
<TR><TH>City:</TH><TD>
<input type="text" name="City" maxlength="20" size="20"></TD></TR>
<TR><TH>Country:</TH><TD>
<input type="text" name="Country" maxlength="20" size="20"></TD></TR>
<TR><TH>Secret Word:</TH><TD>
<input type="text" name="SecretWord" maxlength="20" size="20"></TD></TR>
</TABLE>
</form>
<!-- End form code -->
</body>
</html>
|
|
|
You are missing the ".value" for everything but the first element (FName) you test.
|
|
|
|
|
|
|
|
|
|