【发布时间】:2016-07-31 15:01:32
【问题描述】:
我正在通过 XDK 制作 HTML5 移动应用。我有一些表格,我在网站上使用 Captcha 验证。在我看来,移动应用程序的垃圾评论不会造成任何影响。有没有人看到任何针对移动应用的评论垃圾邮件?您认为我需要在移动应用程序表单中使用 Captcha 验证还是让它不打扰用户?
【问题讨论】:
标签: mobile captcha spam intel-xdk
我正在通过 XDK 制作 HTML5 移动应用。我有一些表格,我在网站上使用 Captcha 验证。在我看来,移动应用程序的垃圾评论不会造成任何影响。有没有人看到任何针对移动应用的评论垃圾邮件?您认为我需要在移动应用程序表单中使用 Captcha 验证还是让它不打扰用户?
【问题讨论】:
标签: mobile captcha spam intel-xdk
评论垃圾邮件发生在移动和桌面网站或应用程序上。常用的text验证码验证有助于解决这个问题。
对于移动应用程序,在原生应用程序中自动提交数据更加困难。部分原因是无法编写恶意外部脚本来发现源代码中的元素并调用表单提交。此外,移动应用程序必须购买(免费或付费)并安装在物理设备或模拟器中。
更适合移动应用的验证码:sliderCAPTCHA、imageCAPTCHA、motionCAPTCHA、RingCAPTCHA 和 NuCAPTCHA。
【讨论】:
防止网站和混合应用程序中的垃圾评论和垃圾邮件机器人的最佳方法是通过 JS 或 jQuery 动态创建表单,而不是直接将表单放入视图(HTML 代码)中。通过这种方式,您不需要放置验证码来保护它免受机器人攻击。下面是使用 jQuery 创建表单的示例代码:
// Make THE FORM tag
var $form = $("<form/>", {
appendTo : $("#contactFormSection"),
class : "col-xs-12 col-sm-11",
id : "contactForm",
submit : AJAXSubmitForm
});
//MAKE A HIDDEN INPUT
$("<input/>",{
type : "hidden",
name : "flag", // Needed for serialization
value : "5",
appendTo : $("#nameSection"),
on : { // Yes, the jQuery's on() Method
/*
input : function() {
console.log( this.value );
}
*/
}
});
//Make Name INPUT
$("<input/>",{
type : "text",
class : "formContact",
id : "exampleInputName2",
name : "name", // Needed for serialization
placeholder : "Your Name",
appendTo : $("#nameSection"),
on : { // Yes, the jQuery's on() Method
}
});
//MAKE EMAIL INPUT
$("<input/>",{
type : "email",
class : "formContact",
id : "exampleInputEmail1",
name : "email", // Needed for serialization
placeholder : "Your Email",
appendTo : $("#emailSection"),
on : { // Yes, the jQuery's on() Method
}
});
//MAKE TEXTAREA
$("<textarea/>",{
class : "formContact-text",
rows : "3",
name : "msg", // Needed for serialization
placeholder : "Your message",
appendTo : $("#msgSection"),
});
//submit the form
function AJAXSubmitForm(event) {
event.preventDefault(); // Prevent Default Form Submission
// do AJAX instead:
var serializedData = $(this).serialize();
$.ajax({
url: "Your server API URL",
type: "POST",
data: serializedData,
dataType: 'json',
success: function (data) {
// log the data sent back from PHP
if(data.status){
$('#confirmation').modal('show');
} else{
$('#errorMsg').modal('show');
}
}
});
}
【讨论】: