Share via


Enforcing Custom List Item Data Validation

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Two approaches were considered for validating the Training Course SharePoint list items. One approach was to edit the standard NewForm.aspx and EditForm.aspx pages to add custom validation controls. However, editing standard SharePoint files is not an ideal solution because you lose some of the standard functionality that SharePoint provides, such as the standard appearance and behavior (look and feel) and built-in client side validations. Also, users can circumvent the validation by using the SharePoint Web services or Web-based Distributed Authoring and Versioning (WebDAV).

Another approach is to add custom list item event receivers to the list that holds the items that you want to validate. This approach enables you to use custom business logic that either allows or cancels the addition or editing of a list item. Also, as part of the cancellation process you can specify custom error messages that appear in the standard error page.

Because standard list item fields provide only basic data types and essential field validations, adding custom validation through list item event receivers also allows you to include functions such as performing comparisons with other fields, validating formats, and validating an item's uniqueness. One drawback to this approach is that list item event receivers can be implemented only as server-side code. This approach is not appropriate when client-side validation is required.

For an example of custom validation, see The List Item Event Receivers .

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Footer image

To provide feedback, get assistance, or download additional, please visit the SharePoint Guidance Community Web site.

Copyright © 2008 by Microsoft Corporation. All rights reserved.