heya, howz everyone?
Ive used some java script to validate my coldfusion form. The form that i validated looks like this … just to show u that its not a typical coldfusion form….
<table border=0 width=100%>
<tr>
<td colspan=2 bgcolor=silver><font face=’arial’ size=2>Bill To</font></td>
</tr>
<cfoutput>
<form action=”checkout_getInfo.cfm” method=”post” onSubmit=”return checkForm(this)”>
<input type=”hidden” name=”validatefields” id=”validatefields” value=” Firstname,Lastname,Phone,Fax,Email,Address1,Addres
s2,City,State,Zip”>
<input type=”hidden” name=”total” value=”#total#”>
<input type=”hidden” name=”gogo” value=”gogo”>
<cfloop list=”#dbfields#” index=”i”>
<tr>
<td><font face=”arial” size=1>#i#</font></td>
<td><input type=”text” name=”#i#” width=20></td>
</tr>
</cfloop>
</cfoutput>
</table>
And the java script that i used to validate it with is:
<html>
<head>
<title>Untitled</title>
<script language=”JavaScript”>
<!–
function checkForm(form){
fieldsToValidate = form.validatefields.value.split(“,”);
for(x=0;x<form.elements.length;x++){
for(z=0;z<fieldsToValidate.length;z++){
if(form.elements[x].name == fieldsToValidate[z]){
if(form.elements[x].value == ”){
alert(‘Please enter a value in the field ‘ + fieldsToValidate[z]);
form.elements[x].focus();
return false;
}
}
}
}
}
//–>
</script>
</head>
How could i tweek the java scrip or do somthing without cahnging the form much that would allow me to validate the form more accurately…i.e. so that in the telphone field for eample u cannot enter anything but numbers and in the expiry date (in the other form) u cannot enetr anything but date format.
ANy help would be supperb!!
Thank u soo mcuh for reading this message! Yuriy