嗨,我的网站上有一个联系表格,在这个表格中我有一个 javascript 复选框按钮。
这是我的表单的结束代码:这个 div 标签是我的复选框:
<p><label for="agree">(*) I agree whit the transport terms and conditions:</label><div id="cb"></div></p>
<p>hi
<input name="Submit / Send" type="submit" class="submit" id="Submit / Send" tabindex="370" value="Submit / Send" />
<p id="error_zone" style="visibility:hidden;">Errors: There are some errors in the form. Please correct them.</p>
</p>
这是 javascript 文本按钮:
<script type="text/javascript">
var cbh = document.getElementById('cb');
var val = '1';
var cap = '';
var cb = document.createElement('input');
cb.type = 'checkbox';
cbh.appendChild(cb);
cb.name = val;
cb.value = cap;
cbh.appendChild(document.createTextNode(cap));
</script>
我也对我的其他表单元素使用 spry 验证。我想用 javascript 验证复选框以创建验证码复选框!是否可以让弹出验证按摩而不干扰快速验证?!重要的是,如果关闭了 javascript,则表单将无法再提交。
希望可以有人帮帮我。谢谢你的时间!
我正在尝试实现这一点:http ://uxmovement.com/forms/captchas-vs-spambots-why-the-checkbox-captcha-wins/
spry 验证的片段:
<script type="text/javascript">
var errorsOnSubmit = function(form){
var ret = Spry.Widget.Form.validate(form);
var errorZone= document.getElementById('error_zone');
if (!ret){
errorZone.style.visibility = 'visible';
errorZone.style.backgroundColor = 'red';
}else{
errorZone.style.visibility = 'hidden';
}
return ret;
}
</script>
<script type="text/javascript">
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {isRequired:false, invalidValue:"1", validateOn:["blur", "change"]});
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {isRequired:false, invalidValue:"1", validateOn:["blur", "change"]});
var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3", {isRequired:false, invalidValue:"1", validateOn:["blur", "change"]});