I have an input that I want to set the max value to 255. I’m not submitting the form, but rather calling a function which submits the data via ajax.
Some of the other validate checks are working, like required and digits, but max isn’t working. I’m using jQuery 1.4.4 and validate 1.7.
HTML
<input type="text" maxlength="3" style=" width: 190px" value="" name="Repeats" id="formfield_Repeats">
JavaScript
$(document).ready(function () {
$("#my_form").validate({
rules: {
formfield_Repeats: {
digits: true,
required: true,
max: 255
}
}
});
});
When I go to save the app I call the valid() method on the form.
Is it a version mismatch with jQuery and the validate plugin? I could upgrade both, but the project is HUGE and I don’t necessarily want to have to retest the entire app.
jquery validate uses the NAMES of inputs, not the id’s so you should have:
EDIT:
hmm, ok, let’s try adding the rule directly to the input field:
EDIT:
have a look at this js fiddle: it shows this working exactly as expected with validate 1.7 and jquery 1.4.4
http://jsfiddle.net/Et9vM/