Validating forms using Regular Expressions

Regular Expressions, though long considered a staple of any coder’s arsenal, can be used by anyone who has the tortuous task of finding the appearance of a word in multiple docs but only, say, when that word is in caps. InDesign stalwarts will be familiar with GREP which uses Regular Expressions to search for patterns in text and we can think of it as advanced Find and Replace. The syntax can look a bit daunting but there’s very little to the basics.

When we use form validation in HTML5 we’re using Regular Expressions too  – we’re  just setting the criteria so we can match a pattern in the text that is being entered.

The following is a CodePen I created that uses Regular Expressions to validate a couple of types of form entered data:

See the Pen Patterns by Alan Dargan (CodePen.16446

Leave a Reply

Your email address will not be published. Required fields are marked *