开发者

Validate between fieldsets

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...

My form is set up like this

<form id="SignupForm" method="POST" action="..................">

    <fieldset>
    <legend>Application</legend>
        <div>

        </div>
    </fieldset>

    <fieldset>
    <legend>Step Two</legend>
        <div>

        </div>
    </fieldset>

This is what I'm using at the moment

  $("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;开发者_StackOverflow
                    };
                }; 

                $("#" + stepName).hide();
                $("#step" + (i + 1)).show();
                if (i + 2 == count)
                    $(submmitButtonName).show();
                selectStep(i + 1,'next');
            });
        }

Any ideas anyone?


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');
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜