如何使用Google脚本在Google表单中设置唯一的密码? [英] How can we make a password unique in google form using google script?

查看:62
本文介绍了如何使用Google脚本在Google表单中设置唯一的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下脚本创建一个表单,该表单将仅接受仅存储在Google工作表(A1至A250)中的密码.

The following script creates a form which will only accept passwords that are only stored in the google sheet(A1 to A250).

有一种方法可以使表单不接受使用Google表格中存储的相同密码进行的多个回复.例如,如果我用两个不同的电子邮件ID填写表格,则它不应两次接受.输入密码后,其他人将无法再次使用它.

Is there a way where the form will not accept more than one response using the same password that's stored in the google sheet. For example if I fill the form from two different email IDs then it shouldn't accept it twice. Once the password is entered then nobody else gets to use it again.

function validatePassword() {
  // Create new custom form
  var form = FormApp.create('new');
  var ss = SpreadsheetApp.openById('');
 
  var passwords = ss.getSheetByName('xyz').getRange('A1:A250').getValues();
  // Ex passwords: asd, 123, asd123
  const conditions = passwords.map(element => `${element}`).join('|')
  // Create first question to check the password, it must be required so that the user does not have access to the rest
  // of the form if failed to log in
  var item = form.addTextItem().setRequired(true);
  //item.setTitle('TEST TITLE');
  // Create valid ation for this question matching the password that we got from the sheet
  var textValidation = FormApp.createTextValidation()
    .setHelpText('You must enter the right ID code')
    .requireTextMatchesPattern(conditions)
    .build();
  item.setValidation(textValidation);
}

推荐答案

从问题开始

输入密码后,其他人将无法再次使用它.

Once the password is entered then nobody else gets to use it again.

使用可安装的表单提交触发器删除相应文本数据验证中不应再次使用的密码.

Use an installable on form submit trigger to remove the password that should not be used again from the respective text data validation.

相关

这篇关于如何使用Google脚本在Google表单中设置唯一的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆