Skip to content

Instantly share code, notes, and snippets.

@jericrealubit
Last active June 27, 2017 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jericrealubit/8af8d878fc55629e7804e3e9ab2e1263 to your computer and use it in GitHub Desktop.
Save jericrealubit/8af8d878fc55629e7804e3e9ab2e1263 to your computer and use it in GitHub Desktop.
Creditcard Validation AMEX is not accepted: This validation is in the 4th input box in the credit card input form. Will show error msg when the user input 3 numbers in the 4th input box.
$(document).ready(function() {
var cc_4 = $("input[name='cc_4']");
cc_4.blur( function() { // DEV-599
if ( (cc_4.val().length) == 3 ) {
var no_amex = "Sorry American Express is not accepted.";
if ( $('#cc_number-E').length ) {
$('#cc_number-E span').text(no_amex);
} else {
cc_4.after('<div id="cc_number-E" class="errMsg"><span>'+no_amex+'</span></div>');
}
$("#cc_number-D").addClass('errFld');
} else {
$('#cc_number-E').remove();
$("#cc_number-D").removeClass('errFld');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment