Hi There,
I am trying to write a script that checks that the correct payment method has been chosen based on the first digit of the credit card number. For example for Visa Payment Method the card number needs to start with a “4”. I would like to make this a user event before submit function on sales orders. Any help would be appreciated. Thanks in advance.
function CreditCardCheck(ccnumber, paymentmethod)
{
nlapiLogExecution('debug','type',type);
if (type == 'create')
{
var record = nlapiGetNewRecord();
var ccnumber = /[^\d ]/;
{
// Check Payment Method Visa cards start with 4
if 'paymentmethod'="Visa" && 'ccnumber' => prefixRegExp = /^4/;{
alert('Payment Method is invalid' );
return false;
}
// Check Payment Method mastercard cards start with 5
if 'paymentmethod'="MasterCard" && 'ccnumber' => prefixRegExp = /^5[1-5]/;{
alert('Payment Method is invalid' );
return false;
}
// Check Payment Method Amex cards start with 34 or 37
if 'paymentmethod'="Amex" && 'ccnumber' => prefixRegExp = /^3(4|7)/;{
alert('Payment Method is invalid' );
return false;
}