Technology
 

Sharepoint 2013 : Enforce Custom Validation on a Column

8/14/2013 9:30:53 AM

Scenario/Problem: You want to set more complex validation rules on a column. For example, in a single text column, you might want to prevent users from entering certain words, such as the word test. Or you might want to make sure the user filling in the form types I agree before submitting the form to make the user think twice before submitting it.


Solution: Most column types support a rudimentary type of validation, allowing you to select whether the column must have a value (in most cases). Some columns are even more specific, requiring you to, for example, specify a minimum and a maximum for a Number column. However, sometimes you need more validation options than are available.

Some SharePoint columns support a formula-based validation mechanism similar to Microsoft Excel formulas. This mechanism is available for columns under the Column Validation heading, and this heading is collapsed by default. Expanding this section reveals two additional settings that you can set for the column.

The first option is the formula. Here you can type a formula that is evaluated when the user tries to save the value for that column. For example, you can add a formula to prevent the word test from being used as a value:

=[column_name]<>"test"

In this example, you replace column_name with the name of the actual column you are validating, as shown in Figure 1.

Image

FIGURE 1 Setting custom column validation on a text field.

The second option you can set in this section is the message that is displayed to the user when validation fails. For example, you can write The term “Test” is inappropriate for the Title of an announcement. This message is displayed to the user below the column in red text, as shown in Figure 2.

Image

FIGURE 2 The column validation prevents a user from submitting an announcement with the title Test.

You can also enforce validation based on comparison between two columns. 

 
Others
 
- Sharepoint 2013 : Add a Site Column to a List or Document Library
- BizTalk Server 2010 : Testing BizTalk application — BAPI walkthrough
- BizTalk Server 2010 : Building a BizTalk application — BAPI walkthrough
- BizTalk Server 2010 : Testing BizTalk application — RFC walkthrough
- BizTalk Server 2010 : Building a BizTalk application — RFC walkthrough
- SQL Server 2008 R2 : Understanding Index Structures (part 2) - Nonclustered Indexes
- SQL Server 2008 R2 : Understanding Index Structures (part 1) - Clustered Indexes
- SQL Server 2008 R2 : Understanding Table Structures
- SQL Server 2008 R2 : Data Compression (part 3) - Implementing Page Compression, Evaluating Page Compression, Managing Data Compression with SSMS
- SQL Server 2008 R2 : Data Compression (part 2) - Page-Level Compression, The CI Record
- SQL Server 2008 R2 : Data Compression (part 1)
- Windows 7 : Windows in Your Pocket—Using a Windows Mobile Smartphone - Windows Mobile and Windows 7 (part 3) - Changing Device Settings
- Windows 7 : Windows in Your Pocket—Using a Windows Mobile Smartphone - Windows Mobile and Windows 7 (part 2) - Managing the Device Partnership
- Windows 7 : Windows in Your Pocket—Using a Windows Mobile Smartphone - Windows Mobile and Windows 7 (part 1)
- Windows 7 : Windows in Your Pocket—Using a Windows Mobile Smartphone - Windows Mobile Today
- Windows 7 : Windows in Your Pocket—Using a Windows Mobile Smartphone - History of Windows Mobile
- SharePoint 2010 : Monitoring and Reporting - Editing rule definitions in the health analyzer
- SharePoint 2010 : Monitoring and Reporting - Configuring what gets logged
- SharePoint 2010 : Monitoring and Reporting - Accessing the SharePoint 2010 logging database
- Windows Server 2012 : Using Event Viewer for Hyper-V troubleshooting
 
 
Most View
 
- Exchange Server 2013 : The Exchange Management Shell - EMS basics (part 5) - Server-side and client-side filters
- Exchange Server 2013 : The Exchange Management Shell - How Exchange uses Windows PowerShell
- Windows Server 2008 R2 high-availability and recovery features : Planning for High Availability
- Windows Server 2008 R2 Remote Desktop Services : Installing and Configuring Remote Desktop Services (part 6)
- Learning about Hyper-V for Windows 8 (part 1) - Introducing Hyper-V for Windows 8
- Microsoft Exchange Server 2010 Requirements : Software Requirements (part 1) - Additional Software
- Microsoft Sharepoint 2013 : Using SharePoint Commands (part 1) - Working with the Farm, Working with the Farm Configuration
- Microsoft Visio 2010 : Adding Structure to Your Diagrams - Working with Containers and Their Contents
- Microsoft Excel 2010 : Filtering Options (part 2) - Searching Functions for Listed Items
- Microsoft Lync Server 2013 Edge Server : Edge Server Administration (part 4) - Managing Public Providers
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Sophistication to Your Drawings - Understanding and using layers
- Microsoft Visio 2013 : Adding Sophistication to Your Drawings - Inserting pictures
- Microsoft Excel 2010 : Filtering Options (part 3) - Using the Search Function for Grouped Dates, Using Text, Number and Date Special Filters
- Microsoft Excel 2010 : Filtering Options (part 2) - Searching Functions for Listed Items
- Microsoft Excel 2010 : Filtering Options (part 1) - Filter Listing for Listed Items, Grouped Dates Filter Listing
- Microsoft Excel 2010 : Filtering and Consolidating Data - Preparing Data, Applying a Filter to a Dataset
- Microsoft PowerPoint 2010 : Inserting Charts and Related Material - Formatting a SmartArt Graphic
- Microsoft PowerPoint 2010 : Inserting Charts and Related Material - Resizing a SmartArt Graphic
- Microsoft PowerPoint 2010 : Inserting Charts and Related Material - Modifying a SmartArt Graphic
- Microsoft PowerPoint 2010 : Inserting Charts and Related Material - Using the Text Pane with SmartArt Graphics