Validation Settings In SharePoint

Introduction

Without testing our product, we can't send it to the market. If the software is not fit for business needs, it's worthless. Before selling our product, we have to execute it many times because we have to find out the errors.

After completion of development, we have to set the validation in all the areas because it should 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-the-box validation and custom validations in SharePoint. Please look into the steps given below for all validation fields.

Example. Required Field Validation

Step 1. Open your list and click List Settings at the top of the menu.

Field Validation

Step 2. Under the Columns section, click any Columns.

Columns

Step 3. The next page will come. Look for 'Require that this column contains information' and check Yes.

 Information

Step 4. Go to your list click New and try to add a record. Do not enter any value in the last column.

Test 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.

Step 1. Open your List and go to your List settings -> click your columns.

Now, expand the column validation, go to the Next page, and write your logic here.

User message

Step 2. TODAY(): it will consider Today's date.

If you enter today's date in the B-day column, you will get an error.

Error

Example. Email Validation

Step 1. You can create a column name like Email and the data type should be Single Line text. Go to the formula section and write your code.

Column validation

 Email Validation 

Validate If the Entered Text is Number

=ISNUMBER([My Column]+0)

The field must contain a fixed length or only two symbols

=LEN(Number) = 2

Only no with fixed length

=IF(LEN(CustomSortOrder) = 2, ISNUMBER(CustomSortOrder + 0), FALSE)

Required at least 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
        )
    )
)

The condition between the 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 the SharePoint list or library. In order to create the validation, you have to follow the steps given below.

  1. Navigate to your list.
  2. Select List Tools.
  3. Select List.
  4. Select List settings.
  5. Select Validation settings.
  6. Use the above formula.
  7. Set your user message (Hello World).
  8. Complete.


HCL Tech
HCL Tech