JQuery CreditCard validator extend


I am using Jquery Validator My challenge is when the user is updating their profile info. but not changing their CC .

When in the update page i only show 4*<strong><em>*</em>**</strong>*1111

So the validation fails if use: (code snippet below)

$("#profile-form").validate({ rules: { ccnum: { required: true, creditcard: true }, exp_year: { ccDate: true}, exp_month: { ccDate: true} }

But if the user enters a new CC number it does what it is suppose to.

So my problem what can i do if the user wants to update something else and leave the CC card un-touched.

Any ideas/suggestions?


I would write a new rule that calls the credit card validation method if the element's value has changed:

$.validator.addMethod("creditcard-custom", function (value, element) { return this.optional(element) || element.value === element.defaultValue || $.validator.methods.creditcard.call(this, value, element); }, $.validator.messages.creditcard);


$("#myform").validate({ rules: { ccnum: { required: true, 'creditcard-custom': true }, exp_year: { ccDate: true }, exp_month: { ccDate: true } } });

<strong>Example:</strong> <a href="http://jsfiddle.net/andrewwhitaker/kqczf/2/" rel="nofollow">http://jsfiddle.net/andrewwhitaker/kqczf/2/</a>


  • Combine a positive lookahead and negative lookahead?
  • How to get the input from a text box on a webpage form
  • I want to bind the click event to the li elements in the xpages type-ahead
  • need to identify dynamic input/textareas when inserting to database
  • How to dynamically generate javascript using ScriptSharp?
  • ValidationResult Returned From IValidatableObject.Validate Is Not Localized
  • iOS Validation failed -> Bundle is invalid (Xcode 6.2, iOS 8.2)
  • jQuery - how to validate a date of birth using jQuery Validation plugin?
  • Safari PHP form submission -file upload hangs
  • How do I obtain a list of files that changed from svn over a date range?
  • How to Divide an array on c#?
  • How to get value from merged-cells in Excel document using OpenXML and C#
  • How to validate a year I enter in textbox using jquery rule?
  • Laravel at least one field is required
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • Is there some graphical way to create my own configuration file on SonarLint?
  • as3-flash: any way to access all the instances placed in different frames from document class?
  • Does Mobilefirst provide a provision to access web services directly?
  • Parse a date string in a specific locale (not timezone!)
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • htaccess add www if not subdomain, if subdomain remove www
  • Caching attributes in superclass
  • Is there a javascript serializer for JSON.Net?
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Validaiting emails with Net.Mail MailAddress
  • Where to put my custom functions in Wordpress?
  • jQuery tmpl and DataLink beta
  • Compare two NSDates in iPhone
  • Buffer size for converting unsigned long to string
  • SQL merge duplicate rows and join values that are different
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Proper way to use connect-multiparty with express.js?
  • How to set the response of a form post action to a iframe source?
  • sending mail using smtp is too slow
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?