我正在制作多步注册表。为此我已经为表格标签内的每个步骤创建了带有下一步按钮的div,如下所示......
<form action="" method="POST">
<div class="registration_step_1 clearfix">
/*few form fields here such as username, password etc.*/
/*Button to proceed to next step*/
<button class="redBtn right_part step_btn">Next</button>
</div>
<div class="registration_step_2 clearfix">
/*few form fields here such as username, password etc.*/
/*Button to proceed to next step*/
<button class="redBtn right_part step_btn">Next</button>
</div>
<div class="registration_step_3 clearfix">
/*few form fields here such as username, password etc.*/
/*Button to proceed to next step*/
<button class="redBtn right_part step_btn">Next</button>
</div>
<div class="registration_step_4 clearfix">
/*few form fields here such as username, password etc.*/
/*Button to proceed to next step*/
<button class="redBtn right_part step_btn">Next</button>
</div>
<div class="registration_step_final clearfix">
<input type="submit" value="Register" class="redBtn round-button">
</div>
</form>
我正在使用位置绝对形式验证引擎。
我们可以触发验证如下: jQuery的( “#formID”)validationEngine();
问题是每个步骤都可以包含很少的字段。对于最初处理向导,我只显示第一步并显示:没有其他div。但是在这种情况下,当提交步骤1的所有必填字段时,表单将被提交给服务器。
任何人,请建议如何处理这种情况。理想情况下,当填写特定步骤的所有必填字段时,它应该进入下一步而不应提交,反之亦然。
感谢您的所有时间。
答案 0 :(得分:2)
使用javascript(此处为jQuery)阻止表单在每个按钮后提交:
jQuery(".registration_step_1").click(function() { /*some code */ return false; } );