Override client-side validation in mvc forms textbox widget

Posted by Community Admin on 04-Aug-2018 17:22

Override client-side validation in mvc forms textbox widget UI with custom EegEx

All Replies

Posted by Community Admin on 21-Jan-2016 00:00

Is there a way to override the default client-side validation on an MVC form field with custom RegEx?

For example, in my form designer, I add a textbox for a phone number. When editing the TextBox, in the Limitations tab, there is a Type dropdown where different validation types can be selected. One of the types listed is "Tel", which I'm assuming means telephone. I selected the "Tel" type (and checked the Required field box). However, when testing the form, the client-side validation only requires that a single alphanumeric character ("a") needs to be entered in the Phone textbox in order to pass validation. The form posts back, but returns an "Entry is not valid!" message from the server-side validation since "a" is obviously not a valid phone number.

 

In Advanced/Model/ValidatorDefinition I have added my ph regex (^\+?(\d[\d-. ]+)?(\([\d-. ]+\))?[\d-. ]+\d$) to the RegularExpression field and set the  ExpectedFormat field to "Custom", but Ive still been unable to change the client-side validation.

Is there a way to override/customize the client-side validation through the textBox UI with a custom regex? If so, what am I doing wrong?

Thanks,

 

-Mark

This thread is closed