dongtui2029 2013-08-27 23:11 采纳率: 0%
浏览 27
已采纳

多步表单验证[关闭]

I am new to jQuery and I have no idea on how to implement some jQuery validation on a jQuery form I downloaded.

I am using this form: http://thecodeplayer.com/walkthrough/jquery-multi-step-form-with-progress-bar

Server side validation is already done in php but I need jQuery so that the users cannot click on the Next button if they haven't wronte anything on those fields.(same behavious as the required html attribute for input tags)

I've tried all sorts of things by copying and pasting jQuery validation code from other people but without any success. So if anyone could help me out on this issue I would really appreciate it (will buy you a penguin as I am a linux admin =p )

Kind regards, Ciprian

  • 写回答

1条回答 默认 最新

  • dongyi1441 2013-08-28 00:38
    关注

    First you'll want to include a Validation Plugin. Here's a really good one.

    Then you'll want to add the required tag to all inputs required.

    Then when the user clicks the 'Next' buttons, you'll want to validate the form like so.

    $('#msform').validate();
    if (!$('#msform').valid()) {
        return false;
    }
    

    Place the above code right after $(".next").click(function(){ and you'll be set.

    I've built a working copy of this code here. The inputs on the first slide are required. Then on the next slide, the first input is required.

    Please note that this project requires three JavaScript files:

    <script type="text/javascript" src="http://thecodeplayer.com/uploads/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="http://thecodeplayer.com/uploads/js/jquery.easing.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏