Try this:
$.extend($.fn.validatebox.defaults.rules, {
validDate: {
validator: function(value){
var date = $.fn.datebox.defaults.parser(value);
var s = $.fn.datebox.defaults.formatter(date);
return s==value;
},
message: 'Please enter a valid date.'
}
});
Hi, i am trying to use this code to validate my dateboxes. It works fine and displays a message when the user enters wrong date, but is there a way we can empty the datebox field along with the message. Because if the user ignores the messages, the form is still being submitted with wrong value. please advise.
I tried the following, but it empties the datebox field as soon as I enter a character.
Is there a better solution?
$.extend($.fn.validatebox.defaults.rules, {
validDate: {
validator: function(value, element){
var date = $.fn.datebox.defaults.parser(value);
var s = $.fn.datebox.defaults.formatter(date);
if(s==value){
return true;
}else{
$(element[0]).datebox('setValue', '');
return false;
}
},
message: 'Please enter a valid date.'
}
});