I want to use a Google Form to populate a Google Spreadsheet. One of the fields is email address, and I need to validate this against the list of emails for our organisation - in other words forcing people to use valid and existing email addresses.
Our organisation uses Google Apps. The form will be created by a user who is in our organisation and only email addresses from our organisation/domain will be considered valid.
The best way to "validate" an email addresses is to simply have them type it twice and run a Regex check that gives a WARNING to the user that it doesn't look like a valid email address if it does not match the pattern, and asks the user to double check.
With Email Notifications, you can automatically send a confirmation email to respondents after they submit your Google Form. You can create a pre-written auto-responder template and the form submitter will get your confirmation email almost instantly.
Just click the triple dot on the lower right of the field. Then choose Regular expression and Matches on the following drop downs. Use the regular expression below to accept valid names generally, and input an error message if the regular expression is not followed.
You can add response validation to restrict the answers that users can enter for a question. To add a response validation, select a question in Google Forms, click on ⋮ More icon and select show Response validation. The response validations that you can add varies by question type.
Now you can put a Regular Expresion in the field:
For EMAIL:
[a-zA-Z0-9_\.\+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-\.]+
You can use the experimental Apps Script Domain Services API. Here's how I'd do it.
function isValidEmailInMyDomain(address) {
var parts = address.split('@');
if( parts.length != 2 )
return false;
if( parts[1] != UserManager.getDomain() )
return false;
try {
UserManager.getUser(parts[0]);
return true;
} catch(doesNotExist) {
return false;
}
}
function testFunction() { //check the menu View > Logs
Logger.log(isValidEmailInMyDomain('[email protected]'));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With