在字段集之间验证

编程入门 行业动态 更新时间:2024-10-26 18:21:16
本文介绍了在字段集之间验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用带有低音强度验证的formtowizard jQuery插件.我已将我的下一个按钮附加到一个单击事件上,该事件可验证我的表单,但是我只希望它校验当前的字段集而不是整个表单...

I'm using the formtowizard jquery plugin with bassistance validation. I have attached my next button to a click event which validates my form however I only want it to validate the current fieldset not the whole form...

我的表单是这样设置的

<form id="SignupForm" method="POST" action=".................."> <fieldset> <legend>Application</legend> <div> </div> </fieldset> <fieldset> <legend>Step Two</legend> <div> </div> </fieldset>

这是我目前正在使用的

$("a.next").click(function() { $("#SignupForm").validate(); });

这是我的按钮被调用的地方

This is where my button gets called

function createNextButton(i) { var stepName = "step" + i; $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>"); $("#" + stepName + "Next").bind("click", function(e) { /* VALIDATION */ if (options.validationEnabled) { var stepIsValid = true; $("#"+stepName+" :input").each(function(index) { checkMe = element.validate().element($(this)); //stepIsValid = !element.validate().element($(this)) && stepIsValid; stepIsValid = checkMe && stepIsValid; }); //alert("stepIsValid === "+stepIsValid); if (!stepIsValid) { return false; }; }; $("#" + stepName).hide(); $("#step" + (i + 1)).show(); if (i + 2 == count) $(submmitButtonName).show(); selectStep(i + 1,'next'); }); }

有任何想法吗?

推荐答案

好,如果有人想知道...,我已经设法解决了我的问题.

Ok I've managed to solve my problem if anyone else would like to know...

function createNextButton(i) { var stepName = "step" + i; $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>"); $("#" + stepName + "Next").bind("click", function(e) { if (options.validationEnabled) { var stepIsValid = true; $("#"+stepName+" :input").each(function(index) { checkMe = element.validate().element($(this)); //stepIsValid = !element.validate().element($(this)) && stepIsValid; stepIsValid = checkMe && stepIsValid; }); alert("stepIsValid === "+stepIsValid); if (!stepIsValid) { return false; }; }; $("#" + stepName).hide(); $("#step" + (i + 1)).show(); if (i + 2 == count) $(submmitButtonName).show(); selectStep(i + 1,'next'); }); }

更多推荐

在字段集之间验证

本文发布于:2023-07-16 23:09:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126887.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!