I have two inputs fields of date:
<input type='text' id='txtLeaveDate' name='txtLeaveDate' class='date' />
<input type='text' id='txtArriveDate' name='txtArriveDate' class='date' />
validation script:
$().ready(function() {
// validate the comment form when it is submitted
// validate signup form on keyup and submit
$('#ticketform').validate({
rules: {
txtLeaveDate: 'required',
txtArriveDate: 'required'
},
messages: {
txtLeaveDate: 'Required!',
txtArriveDate: 'Required!'
}
});
});
</script>
and datepicker script:
$('.date').datepicker({
dateFormat:'dd.mm.yy',
onClose: function () {
$('.date').valid();
}
});
But always I have error messages: ‘Required’.
Additionaly, I want to do that #txtArriveDate mustn’t be earlier than #txtLeaveDate, but I don’t know is it possible.
Because my input had
class='date‘, it was validated and was wrong. I had one message Required! for all of the problems. That was reason.To second part I uset this tutorial: http://jquerybyexample.blogspot.com/2012/01/end-date-should-not-be-greater-than.html