如何一次用两个结果进行两个验证
how to make two validation at a time with two result
我创建了一个带有两个复选框的验证。
在javascript
下两个验证都可以正常工作让我给你看看我的代码
javascipt
function Validation_agree(){
if(document.form1.agreed1.checked==false)
{
$(".agreement_main").show();
return false
}else{
$(".agreement_main").hide();
}
if(document.form1.agreed2.checked==false)
{
$(".agreement_terms").show();
return false
}else{
$(".agreement_terms").hide();
}
}
的形式类似于
<div class="checkme">
<label><input type="checkbox" value="" name="agreed1" />I have discussed all of the order details above and the customer is happy to proceed</label>
<br />
<div class="alert agreement_main" style="display:none;">Please confirm you have informed the customer of the T&Cs</div>
</div>
<div class="redNote">
<label><input type="checkbox" value="" name="agreed2" />I have informed the customer where they can find the T&C’s on the BT.com website</label></p>
<div class="alert agreement_terms" style="display:none;">Please confirm you have informed the customer of the T&Cs</div>
</div>
<input type="submit" value="submit order" /></div>
</form>
问题是……其中一个在更新另一个后工作
当按下提交按钮时,显示第一个验证错误消息。我想一次进行两个验证检查
下面的代码可能适合你。
function Validation_agree(){
var isValid = true;
if(document.form1.agreed1.checked==false)
{
$(".agreement_main").show();
isValid = false;
}else
{
$(".agreement_main").hide();
}
if(document.form1.agreed2.checked==false)
{
$(".agreement_terms").show();
isValid = false;
}else{
$(".agreement_terms").hide();
}
return isValid;
}
相关文章:
- 如何在datetimepicker中使用两个验证器
- angularjs复选框验证至少两个
- 我这里有两个表格,在提交验证第一个表格后,我如何转到第二个表格进行验证
- jquery.validator和一个页面上的两个联系人表单将在提交时验证空表单
- JQuery 验证 - 如何检测“&”键(只允许“&”而不是“7”,因为两个键码都是“55”)
- 电子邮件验证不接受仅包含两个字符的域
- Javascript-如何验证两个电话号码是否不同
- 两个不同提交按钮的javascript验证
- jQuery验证插件-比较两个选择下拉列表的自定义方法
- 如何在客户端验证中验证两个变量规则
- Jquery验证插件两个按钮
- 如何使用JS/jQuery验证两个下拉字段中的时间值
- 使用一个提交按钮验证两个字段
- 验证两个输入之间的一个输入
- 带有复选框的jQuery验证场景有两个部分
- Javascript:需要帮助验证表单的两个方面,然后启用“提交”按钮
- 正则表达式用于验证两个范围之间的数字
- 如何验证日期必须从两个日期中不少于一年
- 如何使用javascript验证两个文本区域
- 如何一次用两个结果进行两个验证