【发布时间】:2019-03-14 01:32:20
【问题描述】:
以下代码在用户提交表单时运行。在检查提交的表单数量后(用户只能提交 5 次),表单会记录在服务器端的 google sheet 中。
function validateForm(form){
if(count>=MAX){
var msg={
title:"Idea limit reached",
body:"You can propose a maximum of "+MAX+" ideas for this theme",
btn:"OK"
}
screenMessage(msg)
}
else{
var msg={
title:"Idea recorded",
body:"You can still submit "+(5-count-1)+" ideas",
btn:"OK"
}
google.script.run.withSuccessHandler(successMessage(msg), resetForm()).recordIdea(form)
count++
}
return false;
}
function resetForm(){
$('#title').val("")
$('#description').val("")
$('input[name="tags"]').val("")
$('.creation-tags').empty()
$('.suggested-tags').empty();
}
我的问题是查数据库的时候,我输入的信息是空的!这意味着“resetForm”函数实际上是在表单提交之前调用的。
有没有办法确保只有在用户输入的值被成功提交后才调用resetForm函数?
我尝试将函数嵌套在 successMessage 函数中,但没有得到肯定的结果
【问题讨论】:
标签: javascript html forms google-apps-script