+1-888-365-2779
Try Now
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

1 posts, 0 answered
  1. Mark
    Mark avatar
    1 posts
    Registered:
    25 Nov 2014
    21 Jan
    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?

    Thanks,

     

    -Mark

1 posts, 0 answered