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 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?