1

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);
            }
        });

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.