微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

表格未使用Position Absolute的validationEngine插件提交

如何解决表格未使用Position Absolute的validationEngine插件提交

|| 我正在使用validateEngine jQuery插件来验证我的Web表单。验证完成后,我想通过ajax提交表单。表单提交很好,无需附加验证引擎插件。验证有效,但是ajax在完成后不会触发提交表单。我究竟做错了什么:
jQuery(\"form#sign-up\").validationEngine({
    onValidationComplete: function () {
        var first = $(\"input#first\").val();
        var last = $(\"input#last\").val();
        var email = $(\"input#email\").val();
        var pass = $(\"input#pass\").val();



        var dataString = \'first=\' + first + \'&last=\' + last + \'&email=\' + email + \'&pass=\' + pass;

        //to send the ajax request  
        $.ajax({
            type: \"POST\",url: \"./register.PHP\",data: dataString,success: function () {
                $(\'#sign-up\').html(\"<div id=\'message\'></div>\");
                $(\'#message\').html(\"<h2>Thanks!</h2>\")
                    .append(\"<p>We\'ll send you an email when infoFree is ready to Rock n\' Roll.</p>\")
                    .hide()
                    .fadeIn(500,function () {
                    $(\'#message\').append(\"<img id=\'checkmark\' src=\'./assets/images/check.png\' />\");
                });
            }
        });
    }
});
    

解决方法

验证引擎会阻止表单实际提交,因此,无需在onValidationComplete内做任何事情,只需将其全部提交到提交表单的函数中即可:
$(document).ready(function() {
  $(\"form#sign-up\").validationEngine();
  $(\"form#sign-up\").submit(function(){
    var first = $(\"input#first\").val();
    var last = $(\"input#last\").val();
    var email = $(\"input#email\").val();
    var pass = $(\"input#pass\").val();

    var dataString = \'first=\'+ first + \'&last=\' + last + \'&email=\' + email + \'&pass=\' + pass;

    //to send the ajax request  
    $.ajax({
      type: \"POST\",url: \"./register.php\",data: dataString,success: function() {
        $(\'#sign-up\').html(\"<div id=\'message\'></div>\");
        $(\'#message\').html(\"<h2>Thanks!</h2>\")
        .append(\"<p>We\'ll send you an email when infoFree is ready to Rock n\' Roll.</p>\")
        .hide()
        .fadeIn(500,function() {
          $(\'#message\').append(\"<img id=\'checkmark\' src=\'./assets/images/check.png\' />\");
        });
      } 
    });
  });
}); // ready
〜Cyrix     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。