SharePoint column validation for only numbers with fixed length

Here is how to set column validation formula for SharePoint field to contain only numbers and only two symbols (fixed length). You have to use a “single line of text” field because the number field won’t work this way.

Here is the formula:


This works for both SharePoint 2010 and 2013 and can be set in the user interface.

If you are creating a WSP:

Here is the xml for the field called “CustomSortOrder” is a required field with the deafult value set to “00”:

<Elements xmlns="">
  <Field ID="{[id]}" Name="CustomSortOrder" DisplayName="Sort Order" Type="Text" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="2" Group="CustomField">
    <Validation Message="The value of this field must be between 01 and 99 and with 2 characters.">
</Validation> </Field> </Elements>


In my search for this solution I found some other formulars at The Chris Kent blog:


Happy SharePointing.