SharePoint 2010 column Validation

Abstract:

Many friends have been written many relevant aspects of the article, but I still want to record inside myselt blog.

SharePoint2010 introduct many new functions in the list level, there are managed metadata services, field uniqueness and field value Validation.

FieldUnique is very useful , but do not need too much introduction, managed meta data services will also open other article to describe, this article will focus on validation of the related content field values​​. (Now add just a few simple examples, the follow-up and a reference to new and more complex will further improve the article)

First of all be noted that there are two levels field value validation  in the SharePoint2010 , one is the field level, one is the list level, field-level validation is usually used in field inspection of the contents of their input, and a list of levels The check can be used in the comparison example, the value of two fields in such a scenario.

Field-level validation settings:

When you create a new field  and click on "Validation", note the name of Region for the field.

SharePoint 2010 column Validation

Saved if we input the value of non-China, there will be the following error message:

SharePoint 2010 column Validation

Can also have a bit more complicated scenes, such as the length of the input text to do check:

Set in the Formula = LEN ([REGION]) <8, the following results

SharePoint 2010 column Validation

Check the list of level settings:
Check the list of level set in the list settings page, check the Settings link:

SharePoint 2010 column Validation

There are two types of date fields Date1 and Date2, set the following requirements must be Date2 after Date1.

SharePoint 2010 column Validation

Interestingly, however, this error has to add a new record in the top of the screen not next to the field and (of course, next to the field if you want to put it on the field which field next to it?)

SharePoint 2010 column Validation

SharePoint 2010 column Validation

The types of supporting field validation:

Single line of text
Multiple lines of text
Digital
Currency
Date

Field Types

In this simple example we used a "Single Line of Text" field type. The following field types can be validated with the "Column Validation" feature:

  • Single Line of Text
  • Choice (single only)
  • Number
  • Currency
  • Date & Time

Formulas

  1. You can only compare column values to one another in a list level validation.
  2. A validation formula at the column level cannot include any other columns besides itself. For example, [Column1]>[Column2] is an invalid formula and SharePoint will not allow it to be used at the column level. In this case, you want to use list-level validation.
  3. There is only one formula available at the list level.
  4. The formula syntax is similar to that used in Calculated Columns

There are a few dozen functions available - I have not tried every one. One interesting thing to note is that SharePoint 2010 would not allow me to use the TODAY function, even when validating a Date field. [DateColumn]>TODAY is not a valid validation formula.

Conflicts

  1. What if you have both column level validation and list level validation?
    1. The column level formulas will be evaluated first, then the list formulas
  1. What if the column and list level validations are in conflict?
    1. Example - at the list level, you require that [Text1] = [Text2], but each column has it's own validation; [Text1]="AAA", and [Text2]="BBB". In this case, it will be impossible to actually submit a list item. The column validations are evaluated first, but if the values validate here, they will of course fail the list validation.
  1. What if the list level validation includes columns not included in a particular content type?
    1. If a column used in the list formula isn't available in the current content type, validation will always fail. This means that if you have multiple content types in your list, you should not validate at the list level for a column that is not included in all content types on the list. These columns can only be validated at the column level.

Site Columns

  1. You can set validation on custom columns of the field types listed above
  2. You can override the validation of a site column at the list level

Items To Investigate

  1. How does validation behave with page fields in a Pages library on a publishing site?
  2. How does validation behave in Office client applications?
  3. Is validation available in the Site Directory? Does it work at site creation time?
  4. Can we use regular expressions in a validation formula?