Currently working on jquery date picker validation. As per the Jquery documentation I managed to show from 1900 to 2015 Sep today date. But the validation should be in if the user age is less than 15 years it should say an alert says Your are not eligble. My Second concern is if i select the date for dob field automatically the errorred class was applied to date of issue field. Normally it should happen when i click the next button.
Here is my jquery code
Kindly help me
var date = new Date(); var currentMonth = date.getMonth(); var currentDate = date.getDate(); var currentYear = date.getFullYear(); $("#txt_dob,#txt_Idt").datepicker({ maxDate: new Date(currentYear, currentMonth, currentDate), changeMonth: true, changeYear: true, yearRange: '-115:+0', }) $("#txt_dob,#txt_Idt").datepicker({ dateFormat: "mm-dd-yy", changeMonth: true, changeYear: true, showButtonPanel: true, yearRange: '-115:+10', beforeShow: function () { setTimeout(function (){ $('.ui-datepicker').css('z-index', 99999999999999); }, 0); }, }).on('change', function() { $('#txt_dob,#txt_Idt').valid(); // triggers the validation test on change }); $("#basicForm").validate({ onkeyup: false, showErrors: function (errorMap, errorList) { var errors = this.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted' : 'You have missed ' + errors + ' fields. Please fill before submitted.'; $("#error_message").html(message); $(".error_msge").show(); } else { $(".error_msge").hide(); } this.defaultShowErrors(); }, errorPlacement: function () { return false; }, highlight: function (element) { if ($(element).is(':radio')) { } else { $(element).addClass('errRed'); } $(element).prevAll('label').find('span.required-star').addClass('text-error-red').removeClass('text-error-black'); }, unhighlight: function (element) { if ($(element).is(':radio')) { } else { $(element).removeClass('errRed'); } $(element).prevAll('label').find('span.required-star').addClass('text-error-black').removeClass('text-error-red'); }, rules: { txt_dob: "required", txt_Idt:"required" } });
Here is the fiddle http://jsfiddle.net/karthic2914/gev7bpjL/
Thanks in advance Mahadevan