Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Java Script
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kolucoms6
Average Member

845 Posts

Posted - 25 June 2007 :  13:23:53  Show Profile

1) On form Submit buton, I call

onsubmit="return val_contact(this);"

2) function val_contact(form) is a function which is getting called on form submit.

3) Inside "val_contact" function, I want to call another function which checks for credit card validity( I have the script for the same) if "CC" is selected.I am using below code, but its not working.(I know it wrong and need guidance on it)


if ( form.PType[1].checked == true )
{
CheckCardNumber(form);
}


Any Help ??

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 25 June 2007 :  14:05:59  Show Profile  Visit HuwR's Homepage
you could try putting an alert just before your if statement to fint out what the value of form.PType[1].checked is, if it does equal true, then I would suggest adding an alert to the CheckCardNumber function to ascertain whether it is getting called.
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 25 June 2007 :  16:16:36  Show Profile
Here is it what happens :

if ( form.PType[1].checked == true )
{
alert(form.PType[1].checked);
alert ( "entered" );
CheckCardNumber(form);
alert ( "leaving" );
}


I do get "true" and "entered" message but not "leaving"

It means its calling CheckCardNumber(form) but some problem with CheckCardNumber(form) function only.

Here is the function :


function CheckCardNumber(form) {
var tmpyear;

tmpmonth = form.searchmthED.options[form.searchmthED.selectedIndex].value;

card = form.slctCCType.options[form.slctCCType.selectedIndex].value;
var retval = eval(card + ".checkCardNumber(\"" + form.txtCC_Number.value +
"\", " + tmpyear + ", " + tmpmonth + ");");

alert(retval);
cardname = "";
if (retval)
// The cardnumber has the valid luhn checksum and matches the
// cardtype's rule.
//return true;
else {
// The cardnumber has the valid luhn checksum, but we want to know which
// cardtype it belongs to.
for (var n = 0; n < Cards.size; n++) {
if (Cards[n].checkCardNumber(form.txtCC_Number.value, tmpyear, tmpmonth)) {
cardname = Cards[n].getCardType();
break;
}
}
if (cardname.length > 0) {
alert("This's " + cardname + " number, not " + card + " number.");
return false;
}
else {
alert("This's not a card number.");
return false;
}
}
}


Edited by - kolucoms6 on 25 June 2007 16:17:48
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 25 June 2007 :  16:19:54  Show Profile
Can I write it as

if ( form.PType[1].checked == true && CheckCardNumber(form))==false)
{
alert("Invalid card");
return false;
}

Edited by - kolucoms6 on 25 June 2007 16:21:35
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07