Link to home
Start Free TrialLog in
Avatar of capturetheflag
capturetheflag

asked on

Credit card java script file will not validate card number on form

Hello,

I am calling a java script function to validate a card number but it will not validate.
All of the other fields will validate or throw an error except for the credit card number field.
The code to validate the card is below.  I have attached the html and other js files in text format to this question.  Thanks for the help

    // Validate that the Credit Card :
    if (checkCreditCard(cardnumber, cardname)) {
    	removeErrorMessage('cardnumber');
    } else {
    	addErrorMessage('cardnumber', 'Credit Card Number is not valid.');
    	error = true;
    }

Open in new window

popcorn-HTML.txt
popcorn-JS.txt
creditcard-JS.txt
popcorn-CSS.txt
SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW: you may need something other than .value for cardname, also "mc" != "mastercard".
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In the getRadioValue function, try first to replace the '' value assigned to the unchecked case with Null or better to another conventional flag value that may avoid trouble in passing it as a string or value in other functions.
Avatar of capturetheflag
capturetheflag

ASKER

Thanks for the help.
capturetheflag, thanks for the points.  There is a diverse group of answers here.  Did you come up with a good answer for this or did you just want to close it out?