More in this section
Forums / Developing with Sitefinity / Override client-side validation in mvc forms textbox widget UI with custom EegEx

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

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Mark
    Mark avatar
    1 posts
    25 Nov 2014
    21 Jan 2016
    Link to this post

    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?




1 posts, 0 answered