Regular expression for validating first name
Unfortunately, most of the Java Script validation schemes I've seen have been very inflexible.
For instance, many scripts validate data when the customer submits the form, but only a few provide instant feedback while the user enters data.
The form is ready for publishing online but before you make it live, how would you ensure that candidates have entered data in the correct format?
And even if the format is proper, is the data itself valid?
The learning curve for Regular Expression may not be very easy for everyone.
Often this results in to underutilization of Regular Expression and true power is not harnessed.
Character Limit – the default text box in a Google form allows users to input any number of characters but you can impose a limit with the help of regular expression.
Here we limit the input to 140 characters much like Twitter. Word Limit – If you would like to limit the number of words that a user can type in the input field of a Google Form, there’s a regex for that as well.
Next select “Matches” in the other drop-down and enter ^(19\d|20[0-1]\d)$ in the input field.
And many scripts are customized to a specific form so that each change to the form requires more work on the developer's part, adding and deleting code from a single, monolithic validation function.
One way to get around some of these limitations is to use regular expressions.
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.
Regular Expressions provide the foundation for describing or matching data according to defined syntax rules.