Author |
Topic  |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 25 June 2007 : 13:23:53
|
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
|
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. |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 25 June 2007 : 16:16:36
|
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 |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 25 June 2007 : 16:19:54
|
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 |
 |
|
|
Topic  |
|