How to check whether the entered age is between the specific limit, using Jquery in html forms
+2
A:
Use the jquery validate library http://docs.jquery.com/Plugins/Validation/ you can take a look there
$("#myform").validate({
rules: {
field: {
required: true,
rangelength: [2, 6]
}
}
});
Chino
2010-03-24 12:19:30
+1
A:
Something like this should work:
$('input#age').change(function() {
var age = parseInt($(this).val(), 10);
if(age < 18 || age > 65) {
alert("Wrong age!");
}
});
Adjust as necessary.
Tatu Ulmanen
2010-03-24 12:19:55
the above function should be inside the ("selector").validate() method, right?
Naimur
2010-03-24 12:23:22
Thanks.. This working perfectly..
Naimur
2010-03-24 12:29:52