Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery validation field by range

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.

like image 882
MicTech Avatar asked Dec 23 '22 11:12

MicTech


1 Answers

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" />
like image 98
tvanfosson Avatar answered Dec 31 '22 02:12

tvanfosson