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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?