Abdu
Abdu

Reputation: 16585

Stopping MaskedEditExtender from validating input in asp.net

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

Answers (3)

edosoft
edosoft

Reputation: 17271

Stop the form from submitting with an invalid date. Use a MaskedEditValidator

Upvotes: 2

Nimesh Madhavan
Nimesh Madhavan

Reputation: 6318

Don't specify mask type as "Date", that should stop this error.

Upvotes: 0

Brad8118
Brad8118

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

Related Questions