jquery - validate date and check if it fulfills certain criteria -
i trying validate date using jquery validator plugin, unable
what trying is: let user choose date datepicker in input field , verify between 18 65 years , if yes, continue submit..
i able regex range limit 16 65. how can achieve above results, troubling me..
here code:
<div class="col-md-6"> <label>age</label> <div class="input-group input-group-sm date datepicker" data-date="" data-date-format="dd/mm/yyyy"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span> <input type="text" value="" readonly="readonly" class="form-control" name="age" id="age"/> </div> </div> </div>
the js code
$("#cmxform").validate({ rules: { age: { regex: /^(?:1[6-9]|[2-5]\d|6[0-5])$/ } }, messages: { age: { regex : "provide age, must atleast 18 years old qualify." } }, errorplacement: function(error, element) { element.attr('title', error.addclass('error').text()); element.attr('placeholder', error.addclass('error').text()); } });
try regular expression
regex: /^(?:1[8-9]|[2-5]\d|6[0-5])$/
Comments
Post a Comment