I am using jquery validator to validate text inputs. The problem I have is, if I click submit it displays all error message correctly. However, on the datepicker input, to clear the error message I have to select the datepicker twice. ie; 1 click to select and it inputs the data correctly. 2nd click to clear the error message.
I read somewhere about using an 'on' event on the datepicker, so I tried that, but it made no difference. I don't think that is coded correctly. I am assuming that the invalid and success classes are part of the validator script. Worth a try.
What could be happening here. Thanks
Sciprt code
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
yearRange: '2011:2037',
dateFormat: 'dd/mm/yy',
minDate: 0,
defaultDate: null
}).on('changeDate', function(ev) {
if($('#datepicker').valid()){
$('#datepicker').removeClass('invalid').addClass('success');
}
});
});
</script>
html code
<label for"datepicker">
<input id="datepicker" name="datepicker" type="text" />
</label>
validator relevant code
Rules/Message section
datepicker:
{
required: true,
date: true
},
datepicker:
{
required: " * required: You must enter a destruction date",
date: "Can contain digits only"
}
.validate()? Since you're using a date picker, why do you need thedaterule? Which datepicker plugin?? What is thechangeDateevent supposed to be?