Introduction
Without testing of our product, we can't send it to the market. If the software is not fit to business needs, it's worthless. Before selling our product, we have to execute it many times becuase we have to find out the errors.
After completion of developement, we have to set the validation in all the areas becuase it shoud be user friendly and flexible in the market.
Similarly in our Application also, we will set validation in all the lists and the libraries. There are few out of box validation and custom validations in SharePoint. Please look into the steps given below for all validation fields.
Example - Required Field Validation
Step1
Open your list and click List Settings in top of the menu.
Step 2
Under Columns section, click any Columns.
Step3
Next page will come. Look for 'Require that this column contains information' and check Yes.
Step 4
Go to your list and click New and try to add a record. Do not enter any value in the last column.
This is the simple required field validation SharePoint List.
Example Date Validation
Validation to check your date of birth and it will compare to today's date. We will validate the date of birth and it must be earlier than the current date.
Steps
Open your List and go to your List settings -> click your columns.
Now, expand the column validation, go to Next page and write your logic here.
TODAY() : it will consider Today's date.
If you are entering today's date in B day column, you will get an error.
Field must contain fixed length or only two symbols
Only no with fixed length
- =IF(LEN(CustomSortOrder)=2,ISNUMBER(CustomSortOrder+0),FALSE)
Required atleast one field
- =COUNTA([Name],[Phone])>=1
Validate Email Address Column
- =AND(
- ISERROR(FIND(" ", [Email],1)),
- IF(ISERROR(FIND("@", [Email],2)),
- FALSE,
- AND(
- ISERROR(FIND("@",[Email], FIND("@", [Email],2)+1)),
- IF(ISERROR(FIND(".", [Email], FIND("@", [Email],2)+2)),
- FALSE,
- FIND(".", [Email], FIND("@", [Email],2)+2) < LEN([Email])
- )
- )
- )
- )
ValidatePhone No Column
- =AND(
- LEN([PhoneNo])=14,
- IF(ISERROR(FIND("(", [PhoneNo],1)),
- FALSE,
- (FIND("(", [PhoneNo]) = 1)
- ),
- IF(ISERROR(FIND(")", [PhoneNo],5)),
- FALSE,
- (FIND(")", [PhoneNo], 5) = 5)
- ),
- IF(ISERROR(FIND(" ", [PhoneNo],6)),
- FALSE,
- (FIND(" ", [PhoneNo], 6) = 6)
- ),
- IF(ISERROR(FIND("-", [PhoneNo],10)),
- FALSE,
- (FIND("-", [PhoneNo], 10) = 10)
- ),
- IF(ISERROR(1*CONCATENATE(MID([PhoneNo], 2, 3), MID([PhoneNo], 7, 3), MID([PhoneNo], 11, 4))),
- FALSE,
- AND(
- 1*CONCATENATE(MID([PhoneNo], 2, 3), MID([PhoneNo], 7, 3), MID(PhoneNo], 11, 4)) > 1000000000,
- 1*MID([PhoneNo], 2, 3) <> 911,
- 1*MID([PhoneNo], 7, 3) <> 911,
- 1*MID([PhoneNo], 7, 3) <> 555
- )
- )
- )
Condition between two fields
- =IF([x],IF([y]<>"",TRUE,FALSE),TRUE)
Validate Zip code
- =OR([ZIP/Postal Code]="",LEN([ZIP/Postal Code])=5,AND(EXACT(UPPER([ZIP/Postal Code]),LOWER([ZIP/Postal Code])), LEN([ZIP/Postal Code])=10,NOT(ISERROR(FIND("-",[ZIP/Postal Code],6)))))
Validate Date
- =EXACT(UPPER(TEXT(LongDate,"MM/DD/YYYY")),LOWER(LongDate))
You can use the formula given above in SharePoint list or library. In order to create the validation, you have to follow the steps given below.
- Navigate to your list.
- Select List Tools.
- Select List.
- Select List settings.
- Select Validation settings.
- Use the above formula.
- Set your user message (Hello World).
- Complete.