Hi,

Earlier in MOSS 2007, it was not possible to validate the value of the field at the time of entering or updating the value in the list items. We could do that, but we had to rely on handlers or custom fields.

Yes, still for some requirement we have to go with these options, but at least for the basic and indeed useful now we have something called column validation in SharePoint 2010.

I have created one Employees List ready in my SharePoint site and I have added three columns to it. It has Joining Date, Leaving Date and weight.

We will see two things here. First is the field level validation and the other is item level validation. You can treat this as a custom field validation and event handler validation.

Go to list setting and then click on the weight and now we can see one new section which says column validation. So go ahead and add below condition and type in the user message that you would like to see when condition becomes false.

Click on ok.

Now being on the list settings page, you can see one more new option which is validation settings. Click on it to open a page.

In validation settings, you can actually compare one field with the other field from the list and then show a message to the user. Here in our list for example, we have two date fields and of course joining date cannot be greater than Leaving date. Hence we need to validate these two date fields.

Hence we put this formula inside it.

Now go to the list and add new item and enter weight less than 50 and enter joining date greater than leaving date and see validation triggering.

Now this is a cool new feature of SP 2010, isn’t it?

But yes do remember that we can have only one list validation, which is unfortunate i think and column validations are evaluated first and then list validation.

Advertisements