|
Author
|
Topic: Please help me debug this form validation.
|
mistcat Member
|
posted July 24, 2000 10:28 AM
Help! I'm trying to run a form validation with the following code, but I get an "object expected" error when I run it. <SCRIPT language="JavaScript"> <!-- function CheckCC(stupidform) { var CCok = true var mystring = stupidform.cnum.value var strlen = stupidform.cnum.value.length for (i=0; i< strlen; i++) { if(mystring.charAt(i) == "-") { CCok = false alert('No Dashes! Please enter your credit card in the form 1111222233334444'); //Temp.focus() i=strlen } if(mystring.charAt(i) == ".") { CCok = false alert('No Periods! Please enter your credit card in the form 1111222233334444'); //Temp.focus() i=strlen } if(mystring.charAt(i) == " ") { CCok = false alert('No Spaces seperating Numbers! Please enter your credit card in the form 1111222233334444'); //Temp.focus() i=strlen } } if(strlen != 16) { alert("Credit Card Number must contain 16 digits! Not " +strlen) CCok = false } return CCok }//--> </script> <FORM NAME="myForm" METHOD = POST ACTION = "/old?u=http%3A%2F%2F64.224.111.216%2Fcgi-bin%2Forder.pl&y=1999"> <td align=right><font face=arial><B>C. Card Number:</B></font></td> <td><INPUT SIZE=20 NAME="cnum" VALUE= "$cnum" onChange="checkCC(document.myForm)"> I chopped this out of my actual page for brevity, the usual <HTML> and all that is in there... Thanks for any insites!!! |
yuccatan Junior Member
|
posted July 24, 2000 02:15 PM
It looks like your onChange value is set to lower case instead of upper:is: onChange="checkCC(document.myForm)" should be: onChange="CheckCC(document.myForm)" Hope this helps! Yuccatan |
mistcat Member
|
posted July 24, 2000 02:43 PM
yah that fixed it... =) Thanks, sometimes its hard to see those things... (grin) -nate |