Question: I have a list. I want add a column for list with this format :

**XX-XXXX**

How to set this Validate for column?

i use [this](http://chrisstahl.wordpress.com/2011/02/06/validate-a-sharepoint-list-column-with-regular-expression/) link , but don't work for me.

Answer: 
You've got a few options.

1) JavaScript validation on form as shown in the link in your question.

It DOES work if done correctly and is probably the quickest way do this.

* Pro - Quick and easy and allows you to provide immediate feedback to user in OnBlur event.
* Cons - limited in what you can do (e.g. can't run server side code to check against another list) and easy to 'get around' e.g. via the DataSheet view.

2) A custom column that applies regular expression validation.

You can use/adapt one of these open source projects

* <http://spregex.codeplex.com/>
* <http://sharepointregex.codeplex.com/>

3) Write your own custom column.

More complex - but allows you to combine server side and client side validation.

* [MSDN - Custom Field Types](http://msdn.microsoft.com/en-us/library/ms446361.aspx)
* [Creating a custom field type for SharePoint 2010](http://www.c-sharpcorner.com/uploadfile/Roji.Joy/creating-a-custom-field-type-for-sharepoint-2010-email-validation-field/)
Though not as easy or powerful as regular expressions, standard Column Validation can use a rich selection of Excel-like string functions. For example...

```
<br>
&nbsp;&nbsp;=IF(LEN([ColumnName])=7,IF(MID([ColumnName],3,1)="-"),TRUE,FALSE),FALSE)&nbsp;&nbsp;&nbsp;-or-<br>
&nbsp;&nbsp;=(LEN([ColumnName])=7)+(MID([ColumnName],3,1)="-")=2

```

Some more complex examples are described at 
<http://sharepointsolutions.com/sharepoint-help/blog/2011/12/how-to-use-or-type-options-in-sharepoint-2010-column-validation/>