验证Google表单中的电子邮件地址 [英] Validating email addresses in Google Forms
问题描述
我想使用Google表单填充Google Spreadsheet.字段之一是电子邮件地址,我需要针对我们组织的电子邮件列表对此进行验证-换句话说,迫使人们使用有效的和现有的电子邮件地址.
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.
我们的组织使用Google Apps.该表单将由我们组织中的用户创建,并且只有来自我们组织/域的电子邮件地址才被视为有效.
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.
推荐答案
您可以使用实验性的Apps脚本域服务 API.这就是我的做法.
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('aEmailIn@yourDomain.com'));
}
这篇关于验证Google表单中的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!