Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Hope this will work http://world.episerver.com/documentation/developer-guides/forms/create-custom-form-element-with-validator/
Thanks Anish,
But that is a totally different path, which takes a lot of time. EpiServer Forms is already providing regex validation and I don't want to customize that, I just want to show the correct message for it. As you may know, ASP.NET data annotation syntax is like this:
[RegularExpression("^([a-zA-Z0-9 .&'-]+)$", ErrorMessage = "Invalid First Name")] public string FirstName { get; set; }
This is a very common scenario for validation.
Thanks again,
Sia
One of my friends at work found the solution.
Create a Forms.xml inside \Resources\LanguageFiles and add this as the content:
<?xml version="1.0" encoding="utf-8" ?> <languages> <language name="English" id="en"> <episerver> <forms> <validators> <episerver.forms.implementation.validation.regularexpressionvalidator> <displayname>Regular expression</displayname> <message>This field should be in the correct format.</message> </episerver.forms.implementation.validation.regularexpressionvalidator> </validators> </forms> </episerver> </language> </languages>
That's not a very ideal solution, because it's a general message for all regex, but still works!
I'm using Form Container on Episerver 9. I've added a custom regex validation for a phone number field.
The validation, itself, works fine, but when the input is not a valid phonenumber, the error message is "Validation failed on "Phone Number" field: This field should be in "^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$" format."
How can I show a simple "phone number is not valid" instead of that (without a hacky piece of js code).
Thanks,
Sia