Reputation: 3170
I have an input text which (asp textbox) which is using the jquery ui datepicker. I was testing this input and discover that I can enter text by writing and when i do this I can write this ////
Is there a way to validate while writing and continue using the functionality of the datepicker?
Mi code of the text is this:
var dates = $('#<%= txtFechaDesde.ClientID %>, #<%= txtFechaHasta.ClientID %>').datepicker({
showOn: "both",
buttonImage: '<%=ResolveUrl("~/images/iconos/calendar.gif") %>',
buttonImageOnly: true,
dateFormat: 'dd/mm/yy',
onSelect: function (dateText, inst) {
var option = this.id == "<%= txtFechaDesde.ClientID %>" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
dateText, instance.settings
);
dates.not(this).datepicker("option", option, date);
}
});
Upvotes: 1
Views: 1305
Reputation: 4874
One of the ways that I do this is to create a listener for the keyup
event on the textbox and then use a date parser to determine if the date is valid (I think that some of them, maybe date.js, have an isDate
method which might come in handy here). Then depending on the result, you could have it clear the textbox, highlight it, or some other means to inform the user that their data is invalid.
Upvotes: 1