Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript UI选项卡,下一个上一个按钮,使用完整HTML进行查询验证_Javascript_Jquery - Fatal编程技术网

Javascript UI选项卡,下一个上一个按钮,使用完整HTML进行查询验证

Javascript UI选项卡,下一个上一个按钮,使用完整HTML进行查询验证,javascript,jquery,Javascript,Jquery,我正在使用jQuery验证执行UI选项卡,同时还执行next和previous按钮功能。所有这些都在工作,但验证没有。如何解决此问题 我把我的HTML和JavaScript代码都放在下面 HTML: JavaScript: 您的验证是什么…解释您进行了哪些验证以及哪些不起作用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-trans

我正在使用jQuery验证执行UI选项卡,同时还执行next和previous按钮功能。所有这些都在工作,但验证没有。如何解决此问题

我把我的HTML和JavaScript代码都放在下面

HTML:

JavaScript:


您的验证是什么…解释您进行了哪些验证以及哪些不起作用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.3/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.3/jquery-ui.js"></script>
<script src="jquery.steps.js"></script>
<script src="jquery.validate.js"></script>
<script src="jquery.ui.core.js"></script>
<script src="jquery.ui.widget.js"></script>
<script src="tabs.js"></script>


<script type="text/javascript" src="jsfile1.js"></script>
<link rel="stylesheet" href="jquery.steps.css" />

<div id="tabs">
  <ul>
  <li><a href="#account">1. Account</a></li>
    <li><a href="#profile">2. Profile</a></li>
    <li><a href="#warning">3. Warning</a></li>
    <li><a href="#finish">4. Finish</a></li>
  </ul>
<form id="example-advanced-form" action="#" enctype="multipart/form-data">
  <div id="account">
    <h3>Account</h3>
    <fieldset>
    <legend>Account Information</legend>

    <label for="userName-2">User name *</label>
    <input id="userName-2" name="userName" type="text" class="required">
    <label for="password-2">Password *</label>
    <input id="password-2" name="password" type="text" class="required">
    <label for="confirm-2">Confirm Password *</label>
    <input id="confirm-2" name="confirm" type="text" class="required">
    <p>(*) Mandatory</p>
    </fieldset>


  </div>
  <div id="profile">
    <h3>Profile</h3>
    <fieldset>
    <legend>Profile Information</legend>

    <label for="name-2">First name *</label>
    <input id="name-2" name="name" type="text" class="required">
    <label for="surname-2">Last name *</label>
    <input id="surname-2" name="surname" type="text" class="required">
    <label for="email-2">Email *</label>
    <input id="email-2" name="email" type="text" class="required email">
    <label for="address-2">Address</label>
    <input id="address-2" name="address" type="text">
    <label for="age-2">Age (The warning step will show up if age is less than 18) *</label>
    <input id="age-2" name="age" type="text" class="required number">
    <p>(*) Mandatory</p>
    </fieldset>
  </div>
  <div id="warning">
    <h3>Warning</h3>
    <fieldset>
    <legend>You are to young</legend>

    <p>Please go away ;-)</p>
    </fieldset>
  </div>
  <div id="finish">
    <h3>Finish</h3>
    <fieldset>
    <legend>Terms and Conditions</legend>

    <input id="acceptTerms-2" name="acceptTerms" type="checkbox" class="required"> <label for="acceptTerms-2">I agree with the Terms and Conditions.</label>
    </fieldset>
  </div>

</form>
</div>
<input type="button" id="btnPrevious" value="Previous" style = "display:none"/>
<input type="button" id="btnNext" value="Next" /> 
    </body>
</html>
    $(document).ready(function() {
    alert("1")  
    var form = $("#example-advanced-form").show();

    form.steps({

    headerTag: "h3",
    bodyTag: "fieldset",
    transitionEffect: "slideLeft",
    onStepChanging: function (event, currentIndex, newIndex)
    {
    alert("2")
    // Always allow previous action even if the current form is not valid!
    if (currentIndex > newIndex)
    {
    return true;
    }
    // Forbid next action on "Warning" step if the user is to young
    if (newIndex === 3 && Number($("#age-2").val()) < 18)
    {
    return false;
    }
    // Needed in some cases if the user went back (clean up)
    if (currentIndex < newIndex)
    {
    // To remove error styles
    form.find(".body:eq(" + newIndex + ") label.error").remove();
    form.find(".body:eq(" + newIndex + ") .error").removeClass("error");
    }
    form.validate().settings.ignore = ":disabled,:hidden";
    return form.valid();
    },
    onStepChanged: function (event, currentIndex, priorIndex)
    {
    // Used to skip the "Warning" step if the user is old enough.
    if (currentIndex === 2 && Number($("#age-2").val()) >= 18)
    {
    form.steps("Next");
    }
    // Used to skip the "Warning" step if the user is old enough and wants to the previous step.
    if (currentIndex === 2 && priorIndex === 3)
    {
    form.steps("Previous");
    }
    },
    onFinishing: function (event, currentIndex)
    {
    form.validate().settings.ignore = ":disabled";
    return form.valid();
    },
    onFinished: function (event, currentIndex)
    {
    alert("Submitted!");
    }
    }).validate({
    errorPlacement: function errorPlacement(error, element) { element.before(error); },
    rules: {
    confirm: {
    equalTo: "#password-2"
    }
    }
    });


 var currentTab = 0;
    $(function () {
        $("#tabs").tabs({
            select: function (e, i) {
                currentTab = i.index;
            }
        });
    });
    $("#btnNext").live("click", function () {

        var tabs = $('#tabs').tabs();
        var c = $('#tabs').tabs("length");
        currentTab = currentTab == (c - 1) ? currentTab : (currentTab + 1);
        tabs.tabs('select', currentTab);
        $("#btnPrevious").show();
        if (currentTab == (c - 1)) {
            $("#btnNext").hide();
        } else {
            $("#btnNext").show();
        }
    });
    $("#btnPrevious").live("click", function () {
        var tabs = $('#tabs').tabs();
        var c = $('#tabs').tabs("length");
        currentTab = currentTab == 0 ? currentTab : (currentTab - 1);
        tabs.tabs('select', currentTab);
        if (currentTab == 0) {
            $("#btnNext").show();
            $("#btnPrevious").hide();
        }
        if (currentTab < (c - 1)) {
            $("#btnNext").show();
        }
    });
  });