Hi There,
BTW, you wouldn’t happen to know why the following part of the code isn’t validating. It is not picking up that only letters are allowed in the card name, and is also letting the form be processed with no entry fields for expiry date.
JAVASCRIPT:
for(i=0;i<f.cardname.value.length;i++)
{
if(f.cardname.value.charAt(i).match(“[0-9]”))
{
alert(“Only letters are allowed in your credit card name.”);
return false;
}
}
if (document.detailsform.cardexpfirst.value == “”)
{
alert(“Please enter the expiry date of your credit card.”);
return false;
}
for(i=0;i<f.cardexpfirst.value.length;i++)
{
if(f.cardexpfirst.charAt(i).match(“[a-z|A-Z]”))
{
alert(“Only numerical digits are allowed as an expiry date.”);
return false;
}
}
if (document.detailsform.cardexpsecond.value == “”)
{
alert(“Please enter the expiry date of your credit card.”);
return false;
}
for(i=0;i<f.cardexpsecond.value.length;i++)
{
if(f.cardexpsecond.value.charAt(i).match(“[a-z|A-Z]”))
{
alert(“Only numerical digits are allowed as an expiry date.”);
return false;
}
}
}
</script>
FORM:
<tr>
<td width=8> </td>
<td align=right width=300> <font color=#00549a size=2 face=arial>
<b>Name on Card:</b></font> </td>
<td width=”300″><font color=black size=2 face=arial>
<input type=”text” name=”cardname” size=”30″ >
</font></td>
<td width=”12″> </td>
</tr>
<tr>
<td width=8> </td>
<td align=right width=”300″><font color=#00549a size=2 face=arial>
<b>Expiry Date:</b> </font></td>
<td width=”300″><font color=#00549a size=2 face=arial>
<input type=”text” name=”cardexpfirst” size=”1″
maxlength=”2″>/<input type=”text” name=”cardexpsecond” size=”1″ maxlength=”2″>
<br>
month/year</font></td>
<td width=”12″> </td>
</tr>