I am trying to get a basic validation working which checks all three fields are not empty- so far I can only get it to check the first one….
Here is my code – hope someone can help me to crack it!
<html>
<head>
<title>Page title</title>
<script language=”JavaScript”>
<!–
function checkform()
{
if (custform.custname.value==””)
{
alert (“No Data entered for Customer Name”);
return false;
}
}
{
if (custform.custemail.value==””)
{
alert (“No Data entered for Customer Email”);
return false;
}
}
{
if (custform.custccno.value==””)
{
alert (“No Data entered for Customer Credit Number”);
return false;
}
}
return true;
</script>
</head>
<body MARGINWIDTH=’0 MARGINHEIGHT=’0′ leftmargin=’0′ topmargin=’0′>
<FORM name=”custform” action=”formcheck1.html” onsubmit=”return checkform()” method=”post”>
<table border=’0′ cellspacing=’0′ cellpadding=’0′ width=’100%’>
<tr>
<td>Customer Name</td>
<td><INPUT TYPE=’text’ size=’50’ name=’custname’></td>
</tr>
<tr>
<td>E mail Address</td>
<td><INPUT TYPE=’text’ size=’50’ name=’custemail’></td>
</tr>
<tr>
<td>Credit Card Number</td>
<td><INPUT TYPE=’text’ size=’50’ name=’custccno’></td>
</tr>
<TR>
<TD><input type=’SUBMIT’ value=’click here!!’></TD>
<TD> </TD>
</TR>
</table>
</FORM>
</body>
</html>
Ideally I’d like to have a more advanced validation than just checking for any input – typically checking that the email has a “@” and a “.” and checking that the credit card has a numerical values and is 16 digits….
If anyone knows of any code to do this, I’d appreciate it…..
Many Thanks!!