Google apps script 在Google Apps脚本GUI中使用ClientHandler检测空值
我正在使用谷歌应用程序脚本编写GUI。我有一个文本框,例如txtLastName,我想添加一个客户端处理程序来检测空值。基本上,我想将此字段设置为必填字段。我想有几种可能性,其中之一是使用长度验证器Google apps script 在Google Apps脚本GUI中使用ClientHandler检测空值,google-apps-script,Google Apps Script,我正在使用谷歌应用程序脚本编写GUI。我有一个文本框,例如txtLastName,我想添加一个客户端处理程序来检测空值。基本上,我想将此字段设置为必填字段。我想有几种可能性,其中之一是使用长度验证器 var clientHandler = app.createClientHandler().validateLength(widget, min, max) 要使用此按钮设置可见的警告消息,并最终禁用“提交按钮” 这是非常明确的 下面是一个简单形式的示例,它检查问题1,并显示警告消息: funct
var clientHandler = app.createClientHandler().validateLength(widget, min, max)
要使用此按钮设置可见的警告消息,并最终禁用“提交按钮”
这是非常明确的
下面是一个简单形式的示例,它检查问题1
,并显示警告消息:
function BuildForm() {
var text= new Array();
text =['question 1','question 2','question 3','question 4','question 5','question 6'];
var textBox = new Array();
var app=UiApp.createApplication().setTitle('Form');
var panel = app.createVerticalPanel().setId('panel');
var btn = app.createButton('process');
var warning = app.createLabel('You forgot to fill in question 1').setVisible(false)
for (nn=0;nn<text.length;++nn){
var label = app.createLabel(text[nn]);
textBox[nn] = app.createTextBox().setName(text[nn].replace(' ',''));
panel.add(label).add(textBox[nn])
}
var cliH1 = app.createClientHandler().validateLength(textBox[0], 0, 1)
.forTargets(btn).setEnabled(false)
.forTargets(warning).setVisible(true)
var cliH2 = app.createClientHandler()
.forTargets(btn).setEnabled(true)
.forTargets(warning).setVisible(false)
var servH = app.createServerHandler('process').addCallbackElement(panel).validateLength(textBox[0], 1, 40)
btn.addClickHandler(cliH1)
textBox[0].addClickHandler(cliH2)
btn.addClickHandler(servH)
panel.add(btn).add(warning)
app.add(panel)
var doc = SpreadsheetApp.getActive();
doc.show(app)
}
function process(e){
var app = UiApp.getActiveApplication()
Browser.msgBox(e.parameter.question1+' '+e.parameter.question2+' '+e.parameter.question3+' '+e.parameter.question4+' '+e.parameter.question5+' '+e.parameter.question6)
app.close()
return app
}
函数BuildForm(){
var text=新数组();
文本=[‘问题1’、‘问题2’、‘问题3’、‘问题4’、‘问题5’、‘问题6’];
var textBox=新数组();
var app=UiApp.createApplication().setTitle('Form');
var panel=app.createVerticalPanel().setId('panel');
var btn=app.createButton('process');
var warning=app.createLabel('您忘记填写问题1')。setVisible(false)
对于(nn=0;nn我想有几种可能性,其中之一是使用长度验证器
var clientHandler = app.createClientHandler().validateLength(widget, min, max)
要使用此按钮设置可见的警告消息,并最终禁用“提交按钮”
这是非常明确的
下面是一个简单形式的示例,它检查问题1
,并显示警告消息:
function BuildForm() {
var text= new Array();
text =['question 1','question 2','question 3','question 4','question 5','question 6'];
var textBox = new Array();
var app=UiApp.createApplication().setTitle('Form');
var panel = app.createVerticalPanel().setId('panel');
var btn = app.createButton('process');
var warning = app.createLabel('You forgot to fill in question 1').setVisible(false)
for (nn=0;nn<text.length;++nn){
var label = app.createLabel(text[nn]);
textBox[nn] = app.createTextBox().setName(text[nn].replace(' ',''));
panel.add(label).add(textBox[nn])
}
var cliH1 = app.createClientHandler().validateLength(textBox[0], 0, 1)
.forTargets(btn).setEnabled(false)
.forTargets(warning).setVisible(true)
var cliH2 = app.createClientHandler()
.forTargets(btn).setEnabled(true)
.forTargets(warning).setVisible(false)
var servH = app.createServerHandler('process').addCallbackElement(panel).validateLength(textBox[0], 1, 40)
btn.addClickHandler(cliH1)
textBox[0].addClickHandler(cliH2)
btn.addClickHandler(servH)
panel.add(btn).add(warning)
app.add(panel)
var doc = SpreadsheetApp.getActive();
doc.show(app)
}
function process(e){
var app = UiApp.getActiveApplication()
Browser.msgBox(e.parameter.question1+' '+e.parameter.question2+' '+e.parameter.question3+' '+e.parameter.question4+' '+e.parameter.question5+' '+e.parameter.question6)
app.close()
return app
}
函数BuildForm(){
var text=新数组();
文本=[‘问题1’、‘问题2’、‘问题3’、‘问题4’、‘问题5’、‘问题6’];
var textBox=新数组();
var app=UiApp.createApplication().setTitle('Form');
var panel=app.createVerticalPanel().setId('panel');
var btn=app.createButton('process');
var warning=app.createLabel('您忘记填写问题1')。setVisible(false)
对于(nn=0;nn