Enable Validation in List Definition from Visual Studio 2010 in SharePoint 2010

InfoPath alternatives for form designing SharePoint

Here we discuss how we enable the validation in list definition using visual studio 2010.

Also you can check out:

– Workflow Task and History List not found error in SharePoint 2010

– Assign Manager to user from active directory to SharePoint 2010

– Sequential vs State machine workflows in SharePoint 2010

Follow below Steps:
1. First we need to create the List definition using visual studio 2010.

2. Now we add the two column Start date and End date in element.xml and Schema.xml.

3. Now See the following code for adding the validation in End Date column and add that code under Element.xml and Schema.xml. We also give the message if condition is false. See in code

<Field ID=”{E01F3A97-3526-4073-BFE6-FB7A543488DF}” Name=”Start_Date” DisplayName=”Start Date” Type=”DateTime” Required=”TRUE”></Field>

<Field ID=”{F56FFE7E-9698-470E-9882-4F8CE28ADBA5}” Name=”End_Date” DisplayName=”End Date” Type=”DateTime” Required=”TRUE”>
<Validation Message=”End Date must be larger than or equal to Start Date”>=[End_Date]>=[Start_Date]</Validation>
</Field>

4. Now we save and deploy the solution.

5. Now we go our list definition and add the item.

6. Now if condition is true than item is added but if condition is false than message is showing. See in fig.

Enable Validation in List Definition from Visual Studio 2010 in SharePoint 2010
Enable Validation in List Definition from Visual Studio 2010 in SharePoint 2010

Similar SharePoint 2013 Tutorials


About Navneet Singh

I am Navneet Singh, Working at C3it software solutions pvt. ltd. in Pune. My core skills are SharePoint 2013, Office 365, SharePoint 2010, SharePoint Designer, SharePoint Designer Workflow, Nintex Workflow, Infopath, Webpart, CSOM/SSOM, Power-shell, C#, ASP.NET and SQL Server.

View all posts by Navneet Singh →

Leave a Reply