I have a text box in a New Form (list) on SharePoint 2013 and I am looking for it to recognize (assuming using column validation) 8 and/or 16 digits in sequence and provide a warning that this is not allowed as either a pop up or text alert below the text box.

Essentially looking to restrict account numbers from being entered into the sharepoint with other text. Example : process reversal of fee on account 12345678 - (this should initialize a warning or restriction) and allow the submitter to change to only include the last 4 digits.

Any thoughts or way of doing this?

2 Answers 2


If you can use SharePoint Designer, and only need the validation in a form, you can use a Regular Expression in the New or Edit forms by using the Manage Rules feature.

You cannot not do this using a Calculated Column.

You can add custom JavaScript, also using Regular Expressions, to the page to validate the form field or a SharePoint list column.

The above solutions will not migrate well, or at all, to newer versions of SharePoint or SharePoint Online.

The regular expression might look like \d{8}|\d{16} The above would also match "12345678abc". You could create one to look for eight or sixteen digits with a non-digit before and after.


To restrict the field to only numbers, make it a Number fied:

enter image description here

To restrict the field to only 8 digits, specify the min and max values: enter image description here

To provide a hint for the users, use the Description field:

enter image description here

To limit the field to entering either exactly 8 or exactly 16 digits, use this validation formula:


enter image description here

To provide users with a hint in case they entered wrong data, use the "User message field" under Column validation:

enter image description here

  • Unfortunately the issue is we cannot store account numbers on our SharePoint Environments. The textbox is for the submitter to describe the request. The reason I am looking to restrict it is so the submitter cannot accidentally include full account numbers Apr 21, 2021 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.