Reputation: 6615
I have a form which is in a updatePanel, I am putting masks on all my date fields like so:
jQuery(function ($) {
//phone numbers
DoMasks();
});
function DoMasks() {
//dates
var txtADate = $("#<%=txtADate.ClientID%>");
$(txtADate).mask("99/99/9999");
var txtDOB = $("#<%=txtDOB.ClientID%>");
$(txtDOB).mask("99/99/9999");
}
When I fill out a blank form and put the adate
in, and then select a drop down (which causes postback) the date in the adate
textbox get erased. when I comment out DoMasks();
everything works fine, so it must be something there? please assist.
It works fine if I open a form that already has data saved in it, and the dates are all already filled in, very strange.
Upvotes: 0
Views: 76
Reputation: 21897
What is the format of the date being passed back after the postback? If the date comes back as something like 09-30-2013
that mask will clear the value since it's looking for a date in the format of 09/30/2013
. (note the slashes)
Make sure your dates are coming back with /
. You can do this using a format string like so:
myDate.ToString("MM/dd/yyyy")
Upvotes: 1