单击“下一步”按钮后如何验证我的表单

How to validate my form if next button clicked

本文关键字:下一步 验证 我的 表单 按钮 单击 何验证      更新时间:2023-09-26

我正在编写一个循序渐进的表单。其中包括一个jquery脚本,用于划分我的表单。所以在第一个表单中,我只需要放一个按钮,那就是下一个按钮来让客户进入下一个表单

但我必须处理的是,如果我点击第一个表单上的下一个按钮,它会转到另一个表单,而不会验证第一个表单中的部分。

这里的按钮编码

<input  name="Next"  type="submit" id='button1' value="Next" />

在这里,我认为除了我不擅长jquery之外,jquery脚本还与下一个标签有关。:

$(".next").click(function(){
    if(animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show(); 
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
    step: function(now, mx) {
        //as the opacity of current_fs reduces to 0 - stored in "now"
        //1. scale current_fs down to 80%
        scale = 1 - (1 - now) * 0.2;
        //2. bring next_fs from the right(50%)
        left = (now * 50)+"%";
        //3. increase opacity of next_fs to 1 as it moves in
        opacity = 1 - now;
        current_fs.css({'transform': 'scale('+scale+')'});
        next_fs.css({'left': left, 'opacity': opacity});
    }, 
    duration: 800, 
    complete: function(){
        current_fs.hide();
        animating = false;
    }, 
    //this comes from the custom easing plugin
    easing: 'easeInOutBack'
});

问题是如何进入另一种形式,但要验证第一种形式。提前感谢

表单验证可以像以下表单name="myForm"action="demo_Form.asp"onsubmit="return validateForm()"method="post"一样完成

validateform()函数只返回false:如果输入不是false,则在这种情况下,操作将转到demo_form.asp,在您的情况下,将转到下一步。。。

举个好例子:http://www.w3schools.com/js/js_form_validation.asp