Chandan Dubey

Chandan Dubey

  • NA
  • 17
  • 2.8k

Date validation

Feb 6 2018 4:53 AM
validatationForDateFromAndDateTo: function (dateFromId, dateToId) {
$("#" + dateFromId + ", #" + dateToId).on("change", function () {
var areDatesPresent = true;
var startDateText = $("#" + dateFromId).val();
var leavingDateText = $("#" + dateToId).val();
if (startDateText == "") {
areDatesPresent = false;
Base.setResetErrorMessage('DateFromError', "Date from is required.", true);
}
else { Base.setResetErrorMessage('DateFromError', "", false); }
if (leavingDateText == "") {
areDatesPresent = false;
Base.setResetErrorMessage('DateToError', "Date to is required.", true);
}
else { Base.setResetErrorMessage('DateToError', "", false); }
if (areDatesPresent) {
var startDate = new Date(startDateText);
var leavingDate = new Date(leavingDateText);
if (startDate > leavingDate || $(this).val() == "") {
Base.setResetErrorMessage('DateFromError', "Date from must be less than Date to.", true);
Base.setResetErrorMessage('DateToError', "Date to must be greater than Date from.", true);
$("#GetReport").attr("disabled", "disabled");
}
else {
Base.setResetErrorMessage('DateFromError', "", false);
Base.setResetErrorMessage('DateToError', "", false);
$("#GetReport").attr("disabled", false);
}
}
else { $("#GetReport").attr("disabled", "disabled"); }
});
},
 
 
 when i enter in date text 123456 then it is accepted ., i want to validate these type of input.
 
 

Answers (1)