Search code examples
jqueryjquery-validatedatatablesjeditable

Can Multiple jQuery Validate rules be applied in a single Datatables Jeditable field?


I know this is possible on a regular form field (as well as simple). I have a jquery datatables (www.datatables.net) pulled from an Ajax source. I allow certain persons within our organization to update records directly from this table using the jeditable plug-in featured. The plug itself works great. To validate the input, I include the jquery validate plug in and make the call as shown here:

Demo of validation within page using jeditable, datatables, jquery and validation

As you can see by the demo, validation rules are called using :

{ class : "required" }

and so on. I have tried adding multiple rules to a single field (along with rules available in the validation plug in which dont seem to function here at all) but can't get it work. I have tried using:

{ class : { required : true, email : true } }

as I would have using regular validation but no luck. Anybody had luck on this before?


Solution

  • Looking at the source code, cssclass is added using .addClass():

    if (settings.cssclass != null) {
        input.addClass(settings.cssclass);
        ...
    }
    

    so, you should be able to simply supply the classes in a string delimited by spaces:

    { cssclass:"required email" }