RegEx on SharePoint NewForm

If you want to implement a more complex validation rule on SharePoint imput fields that SharePoint supports out of the box, you can easily implement regular expressions on the SharePoint NewForm or EditForm.

Here is one approach with JavaScript you can use. Copy the content to a txt file within the SiteAsstets library on the SharePoint site. Then, on the NewForm or EditForm, add a new CEWP (Content Editor Web Part) and reference to that txt file.

Note: I provided that code sample with the file extension .js for formatting purposes only. Please save the code with the .txt file extension.