从发布数据到Google电子表格的表单获取成功消息 [英] Getting success message from a form that posts data to google spreadsheet

查看:131
本文介绍了从发布数据到Google电子表格的表单获取成功消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个表单,并将它与Google Docs电子表格相关联。所以当用户输入详细信息时,它会直接转到电子表格并填充它。我在这里接受了这段代码的建议;



http://mashe.hawksey.info/2011/10/google-spreadsheets-as-a-database -insert-with-apps-script-form-postget-submit-method

它在这里完美运行: http://betaburo.markdunbavan.co.uk



我唯一的问题是我想要以创建成功消息和错误消息。

main.js文件中有一些代码基本验证它,但它不工作或识别错误或



谢谢,
Mark

>

解决方案

如果您使用jQuery,您可以检查是否有输入内容。有几种方法可以做到这一点。



例如,如果你想验证你的名字字段,你可以这样做:

 < ($('input#field1')。val()==''){
$('span.successMessage')。hide();
$('span.errorMessage')。show();
}
else {
$('span.successMessage')。show();
$('span.errorMessage')。hide();
}

您也可以在输入中使用.serialize,然后显示成功/错误消息取决于序列化条目的长度(序列化条目中的ID使用.length)。

I have been developing a form and have linked it to the Google Docs spreadsheet. So when a user enters details it goes straight to the spreadsheet and populates it. I took the advice from this bit of code here;

http://mashe.hawksey.info/2011/10/google-spreadsheets-as-a-database-insert-with-apps-script-form-postget-submit-method

It works perfectly here: http://betaburo.markdunbavan.co.uk

My only problem is that I want to create a success message and error messages.

There is a bit of code in the main.js file that basically validates it but it is not working or recognising the errors or the success.

Any help would be much appreciated.

Thanks, Mark

解决方案

If you use jQuery you can check to see that something has been entered. There are a couple ways to do this.

For example, if you wanted to validate your first name field you could do:

if ($('input#field1').val() == ''){
       $('span.successMessage').hide();
       $('span.errorMessage').show();
       }
else {
       $('span.successMessage').show();
       $('span.errorMessage').hide();
     }

You could also use .serialize on the input, then display the success/error message depending on the length of the serialized entry (i.d. use .length on the serialized entry).

这篇关于从发布数据到Google电子表格的表单获取成功消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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