Adding validations to fields in the Sitefinity Form builder

Adding validations to fields in the Sitefinity Form builder

July 27, 2011 0 Comments
Adding validations to fields in the Sitefinity Form builder

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:

image

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:

image

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:

image

and then proceed down to ValidatorDefinition:
image

Here we can fill out the field ExpectedFormat with the formatting the visitor is supposed to follow:

image

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



For example, if we would like our visitors to put an e-mail address in the text box we are configuring, we need to put EmailAddress in the ExpectedFormat field. We can also specify an error message if an invalid e-mail format is supplied:
image

And that’s that – validation is already in place! Let’s test the result:

image

progress-logo

The Progress Guys

View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments
Comments are disabled in preview mode.
Topics
 
 
Latest Stories in
Your Inbox
Subscribe
More From Progress
d12fcc0bdb669b804e7f71198c9619a7
5 Questions Automakers Should Ask to Improve Asset Uptime
Download Whitepaper
 
SF_MQ_WCM
2018 Gartner Magic Quadrant Web Content Management (WCM)
Download Whitepaper
 
What-Serverless-Means-For-Enterprice-Apps-Kinvey
What Serverless Means for Enterprise Apps
Watch Webinar