Search code examples
javascriptjqueryvalidationjquery-validation-engine

Using a funcCall that retrieves multiple fields


Ello, I'm using jQuery-Validation-Engine and i don't know if this is currently possible but, Is there a way for you to possibly use the funcCall in a senario such as this.

I have to check a date range using 2 textboxes. I want to bind funcCall[dateRangeCheck] in such a way that I can get access to 2 fields as opposed to just the one. The end result would would something like this.


dateRangeCheck = function (fields, rules, i, options) {
    if (isDate(fields[0]) && isDate(fields[1])) {
        if (!dateCompare(fields[0], fields[1])) {
         return "* Invalid Date Range";
        }
    }
 };

Or possibly all the fields that a utilizing this particular funcCall like this


dateRangeCheck = function (fields, rules, i, options) {
    for (var i=0;i<fields.length;i++)
       if(!isDate(fields[i]){
          return "* Invalid Date Range";
       }
    }
 };

Is there some way to accomplish this?


Solution

  • Well now jQuery-validation-engine does support date range checking. Just made the commit myself waiting for it to be reviewed. lol, But no to that second example as of now.

    Here is the source. Have a nice day.

    Update

    The latest version does support group validation.