How do I run jQuery form validation by class?

Posted by joshcomley on Stack Overflow See other posts from Stack Overflow or by joshcomley
Published on 2010-03-31T11:46:49Z Indexed on 2010/03/31 11:53 UTC
Read the original article Hit count: 317

Filed under:
|
|

Hi there,

I've been using the jQuery form validator, but I can't seem to figure out how to trigger it by class. Take this example:

$("#myform").validate({
  rules: {
    field: {
      required: true,
      date: true
    }
  }
});

Where field it is expecting the name of the particular input. But, what if I have the following:

<input class="date".... />

How can I tell the validator to validate all inputs with a "date" class as a date?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about validator