Forms - validation
It would be great in the forms module if there were a way to validate entry into some fields other than required or not. Maybe I am missing something, but I would like the ability to have validation tests for SSN or phone number, etc. I am assuming that I could create a custom field type, but a simple RegEx expression on a built-in text field would be better.
You can set forms validation from the UI by setting the ValidatorDefinition in the advanced settings of your text box. Please refer to this blog post for more information.
You can also use client side validation in the template of your designer or try validating the field you want inside your designer script. This thread form our forums explains in detail how you can achieve this.
I hope this information helps. Please contact me if you need further assistance with this issue.
the Telerik team
Thank you for getting back to me. I have logged this functionality as a feature request in our system.To vote for it and follow its status you can visit this public URL. For now you can achieve this through code by setting this.Validator.RegularExpression to the desired regular expresion or if you have custom definition, you can read it from there. Another option, if you're using a custom designer for the field controls is to set this property from the designer.
All the best,
the Telerik team
This is realy very common so please consider adding a regex for e-mail adresses.
Just to update.
I started to make blog posts about stuff I came along in Sitefinity but probably am goint to forget again (old age). Sitefinity Hidden treasure
Forms are such a great feature but if I have to make mental notes that this is possible and how to do it - it will be absolutely impossible for my clients.
Could you consider a dropddown in the UI where the end user can set the type of validation?
I am trying to validate a number that cannot be more than 10 digits long. I've tried every combo of field types/limits/etc. and can't seem to get it to care how long the number is. Please see the attached doc for a summary of my current settings. Using these settings, I can succesfully submit numbers like:
What am I missing? What fields do I need to have set to require an entry to be numbers only, at least 9 numbers, but no more than 10.
Can you try this as in the attached screenshot. Advanced options.
Ah! So that's how to get regular expressions to work. Thank you!
No problem. Hope you got it working the way you want it.
Have a nice day