Compilers use Regular Expressions to validate the syntax of programs.

If the program code does not match the Regular Expression then the compiler indicates that there is a syntax error. When a user clicks the OK button, the program checks to ensure that none of the fields are empty.

At the time of designing the form, expand the “Data Validation” section below the form field (see screenshot above) and choose Regular Expression from the drop-down.

Google Forms makes it relatively easy to add such advanced date validation rules to individual fields through Regular Expressions (or regex or regexp).

Think of them as search patterns and every character entered in a form field is matched against that pattern – the form can only be submitted if the patter and the user-input matches. Say your Google form expects the user to enter their year of birth.

When you are expecting dozens, or even hundreds, of responses in your Google Forms, it is always a good idea to have some rules in place and respondents data should be matched against these rules even before they submit the form.

For instance, if your form is asking for a person’s year of birth, they should only be allowed to enter a number between 19.

The field will now accept input value like 1920, 2010 but would reject other values that fall outside the range.

A regular expression may appear gibberish but they aren’t so difficult to read and understand if you can know the basic rules of the language.If there are no empty fields then the following code validates the first name by calling the static method Match of the Regex class, passing both the string to validate and the Regular Expression as arguments. This object contains a Success property that indicates whether a method Match's first argument matches the pattern specified by the Regular Expression in the second argument.If the value of Success is false (i.e., there was no match) then display an error message and set the focus back to the first Name Text Box so that the user can retype the input and terminate the event handler.If one or more fields are empty then the program displays a message to the user that all fields must be filled in before the program can validate the input information.The code above calls the first Name Text Box's Focus method to place the cursor in the first Name Text Box..What you see here is a compilation of some useful regular expressions that can be used to validate common form fields like URLs, phone numbers, zip codes, dates, etc. Postal Address – allow only alphanumeric characters, spaces and few other characters like comma, period and hash symbol in the form input field. Email Address – the regex below should match most common email address formats, including Gmail aliases that accept the “ ” sign but there’s no perfect solution. URL (Web domain) – this is useful for fields that require the user to enter their website address and it even matches the upcoming TLDs like .directory or .restaurant.