views:

1098

answers:

2

How can I validate field by range?

I use additional-methods, but i don't know how providing parametr with range to my validation method via HTML.

Something of a
<input type="text" class="rangeField" rel="[10, 20]" />

It's nice, if i can make a difference between integer and decimal in validation.

+6  A: 

Are you using the Validation plugin? This plugin makes it trivial to validate against a range.

$("#myform").validate({
  rules: {
    field: {
      required: true,
      range: [13, 23]
    }
  }
});

<input type="text" id="myrange" name="myrange" class="field" />
tvanfosson
A: 

Can you please tell me how can I give range validation with parameter inside of HTML element itself? Thanks in advance..

Suresh