Well here is what I did. As per Nate's suggestion I put the !== to a != and
still it alerts that the value is not correct. As per Dave suggestion I took
off the () after the return false and it submit the page and does a write of
the word false
Im frustrated, this should be easy, but is proving diffucult
Here is the updated code
var type = target.card_type[target.card_type.selectedIndex].value;
var number = target.card_number.value;
var first_number = number.substring(0,1);
var first_two_numbers = number.substring(0,2);
var first_four_numbers = number.substring(0,4);
if ( type == 'VISA' && parseInt(first_number) != 4){
alert("Invalid Card Number");
return false;
}
if ( type == 'MAST' && 1* parseInt(first_two_numbers) < 50 &&
parseInt(first_two_numbers) > 56 ){
alert("Invalid Card Number");
return false;
}
if (type == 'AMEX' && 1* parseInt(first_two_numbers) != 34 ||
parseInt(first_two_numbers) != 37){
alert("Invalid Card Number");
return false;
}
if(type == 'DISC' && parseInt(first_four_numbers) != 6011){
alert("Invalid Card Number");
return false;
}
Doug
----- Original Message -----
From: "Dave Carabetta" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, November 27, 2001 10:30 AM
Subject: Re: OT Quick JS ?
> I don't know if this will solve your issue, but I noticed that you have
> "return false();" instead of "return false;" (without the parens). With
the
> parens, you are asking JS to return a function called false, whereas
without
> them you are returning a value of false.
>
> Just a guess though...
>
>
> ----Original Message Follows----
> From: "Douglas L. Brown" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: CF-Talk <[EMAIL PROTECTED]>
> Subject: Re: OT Quick JS ?
> Date: Tue, 27 Nov 2001 10:34:14 -0800
>
> I am not sure my last comment got sent.
>
> The VISA validation works fine by itself, and I believe the problem to be
> that it is looking at the rest of the script for the CC validation. I
placed
> it below for some insight
>
> 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' && parseInt(first_number) != 4){
> alert("Invalid Card Number");
> return false();
> }
>
> var first_two_numbers = number.substring(0,2);
> if ( type == 'MAST' && 1* parseInt(first_two_numbers) < 50 && 1*
> parseInt(first_two_numbers) > 56 ){
> alert("Invalid Card Number");
> return false();
> }
>
> if (type == 'AMEX' && 1* parseInt(first_two_numbers) != 34 || 1*
> parseInt(first_two_numbers) != 37){
> alert("Invalid Card Number");
> return false();
> }
> var first_four_numbers = number.substring(0,4);
> if(type == 'DISC' && 1* parseInt(first_four_numbers) !== 6011){
> alert("Invalid Card Number");
> return false
>
>
> Doug
>
>
>
> ----- Original Message -----
> From: "Duane Boudreau" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Tuesday, November 27, 2001 10:12 AM
> Subject: RE: OT Quick JS ?
>
>
> > I think if you put quotes around the 4 as in:
> >
> > if ( type == 'VISA' && first_number != "4")
> >
> > Duane
> >
> > -----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();
> > }
> >
> >
> >
> > <CF_SIGNATURE
> > NAME="Douglas L. Brown"
> > EMAIL="[EMAIL PROTECTED]"
> > PHONE="714.538.6611"
> > WEB="http://www.carnivorepc.com">
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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