★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum3/HTML/000473.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  JavaScript
  Please help me debug this form validation.

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Please help me debug this form validation.
mistcat
Member
posted July 24, 2000 10:28 AM     Click Here to See the Profile for mistcat   Click Here to Email mistcat     Edit/Delete Message Reply w/Quote
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     Click Here to See the Profile for yuccatan     Edit/Delete Message Reply w/Quote
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     Click Here to See the Profile for mistcat   Click Here to Email mistcat     Edit/Delete Message Reply w/Quote
yah that fixed it... =) Thanks, sometimes its hard to see those things... (grin)

-nate

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.