The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
The Forms module is one of the new great features we introduced in Sitefinity 4. You can use it to robustly build various user interaction forms, polls, questionnaires and more with the intuitive Sitefinity drag-and-drop interface.
Today we’ll explore the option to add validation to the text boxes, which are possibly the mostly used elements in every form. Let’s first create our form and add some widgets to it:
Now, if we would like to make sure that our visitors fill out the text boxes, there is a tick we can select in the text box’s designer window, which would make any of these fields are required:
So far, so good! However, what if we would like to make sure that the fields are filled out with content with a specific format? For example Text, Number or e-mail address? That’s absolutely possible and easy too! We need to go into the Advanced options of the textbox widget first:
and then proceed down to ValidatorDefinition:
Here we can fill out the field ExpectedFormat with the formatting the visitor is supposed to follow:
The different formatting options are listed in the offline Sitefinity documentation, that's available with the SDK. For ease of access, I've enclosed them below:
Value | Purpose |
None | none by default |
AlphaNumeric | Validates alpha numerics |
Currency | Validates currency |
EmailAddress | Validates email addresses |
Integer | Validates integers |
InternetUrl | Validates internet urls |
NonAlphaNumeric | Validates non aplhanumerics |
Numeric | Validates numerics |
Percentage | Validates percentages |
USSocialSecurityNumber | Validates US social security numbers |
USZipCode | Validates US zip codes |
Custom | Validates against custom regular expression |
GetRelatedItem | Gets the item (live, temp or master) which is related with the specified item by lifecycle status. The method supports only items of type Content and ILifecycleDataItem |
SetUIStatus | Sets the UI status of a content object depending on whether this object also implements ILifecycleDataItemGeneric |
GetUIStatus | Gets the UI status of a content object depending on whether this object also implements ILifecycleDataItemGeneric |
GetLanguageVersion | Gets the language version. |
GetUIStatusRaw | |
GetLanguageVersionRaw | Gets the language version for the specified culture. |
GetWrapperValue | Gets the wrapper value. |
GetPropertyValue | Gets the property value. |
CopyPropertiesFrom | Copies all the properties of the "from" object to this object if they exist. |
CopyPropertiesFrom | Copies all the properties of the "from" object to this object if they exist. |
CopyPropertiesTo | Copies all the properties of this object to the "to" object |
CopyPropertiesTo | Copies all the properties of this object to the "to" object |
GetSerializationPropertyValueCollection | |
GetListSerializationItemsItems |
And that’s that – validation is already in place! Let’s test the result:
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.