tags:

views:

92

answers:

2

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
+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
the above function should be inside the ("selector").validate() method, right?
Naimur
Thanks.. This working perfectly..
Naimur