Reputation: 16585
I have an asp.net textbox and a MaskedEditExtender control attached to it. The textbox is used for date input. The MaskedEditExtender has MaskType="Date" Mask="99/99/9999".
When the form is submitted with an invalid date, the browser shows a Javascript error "... string was not recognized as a valid datetime".
I know why the error shows up. Is there a way to use the extender to just control what the user enters and not validate or convert the input?
Upvotes: 1
Views: 2760
Reputation: 17271
Stop the form from submitting with an invalid date. Use a MaskedEditValidator
Upvotes: 2
Reputation: 6318
Don't specify mask type as "Date", that should stop this error.
Upvotes: 0
Reputation: 4702
on the text box you and set up a keypress function.
Validate if the key pressed is a number String.fromCharCode(event.which) or event.keycode (ie or FF)
Then can check that the text box is contains valid code and format.
If invalid you can set to a default that is valid or just prevent the keypress by using preventDefault()
if invalid format can disable the submit button also ....
Good luck
Upvotes: 0