The problem is that substring returns a string value and your != comparison is against an integer.
There are two ways to fix this. 1.) Use the parseInt() function on the variable: parseInt(first_number) != 4 or 2.) Turn the integer 4 in to the character 4: first_number != '4' HTH Nate > -----Original Message----- > From: Douglas L. Brown [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 27, 2001 1:07 PM > To: CF-Talk > Subject: OT Quick JS ? > > > I have the following script in which I am validating a CC# > but it always > pops up the prompt even if the first digit is 4, can someone see my > error? > > var type = target.card_type[target.card_type.selectedIndex].value; > var number = target.card_number.value; > var first_number = number.substring(0,1); > if ( type == 'VISA' && first_number != 4){ > alert("Invalid Card Number"); > return false(); > } > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

