How to Add Data Validation in File Upload Forms

When building the form with Forms Studio, you can easily add data validation rules using regex and that will allow to you automatically validate the user’s input. The user will be notified though inline error message of invalid input data before submitting a form.

If you are new here, it would help if you can get a basic understanding of Regular Expressions. They can also be used in Google Docs, Microsoft Word, Google Forms and most text editors.

To get started, sign in to Google Forms Studio with your Gmail account and create a new form or manage an existing form. Here expand any input field and put the data validation rule under the Regex Pattern field.


For instance, the regex [0-9]{5}(-[0-9]{4})? will match U.S. zip code consisting of five numbers with an optional hyphen and four-digit add-on.

The regex [a-zA-Z0-9]{5,10} will match any set of alpha numeric characters that are between 5 to 10 characters in length.

For exact matches, you can enclose the regular expression in the caret (^) and dollar sign ($) markers. A ^ matches the position at the beginning of the input string and a $ matches the position at the end of the string. If any characters are entered other than the required match, the input would be rejected.

^\d{3}-\d{2}-\d{4}$ will only match social security numbers.

^4[0-9]{12}(?:[0-9]{3})?$ will match all Visa card numbers as they start with a 4 and can have either 16 or 13 digits.

^\d{3}[-.]?\d{3}[-.]?\d{4}$ will match US phone numbers.

^[A-Za-z0-9\s\-\’\.]{5,50}$ will match names having anywhere between 5 to 50 characters. These will however not work with non-English accented characters like Düsseldorf or Köln.