2017-02-11 290 views
0

我正在尝试使用Jquery表单验证。但我得到未捕获的范围错误:最大调用堆栈exceeded.i使用物化css。Jquery formvalidation未捕获的范围错误:最大调用堆栈大小超过

这是我收到

Uncaught RangeError: Maximum call stack size exceeded 
at RegExp.[Symbol.replace] (native) 
at String.replace (native) 
at Sizzle (http://localhost:3001/bower_components/jquery/dist/jquery.js:869:26) 
at Function.Sizzle.matches (http://localhost:3001/bower_components/jquery/dist/jquery.js:1405:9) 
at Function.jQuery.filter (http://localhost:3001/bower_components/jquery/dist/jquery.js:2769:15) 
at winnow (http://localhost:3001/bower_components/jquery/dist/jquery.js:2749:18) 
at jQuery.fn.init.is (http://localhost:3001/bower_components/jquery/dist/jquery.js:2807:12) 
at FormValidation.Framework.Bootstrap._getMessageContainer (http://localhost:3001/js/formValidation.min.js:10:13553) 
at FormValidation.Framework.Bootstrap._getMessageContainer (http://localhost:3001/js/formValidation.min.js:10:13639) 
at FormValidation.Framework.Bootstrap._getMessageContainer (http://localhost:3001/js/formValidation.min.js:10:13639) 

错误这是我的jQuery和HTML代码

<form class="col s12 m8 l6" id="frontdesk-form-validation"> 
       <div class="row"> 
        <div class="input-field col s12"> 
         <input id="first_name" name="name" type="text" class="validate"> 
         <label for="first_name">Name</label> 
        </div> 
       </div> 
提交
 </form> 
function saveEnquiry() { 
        $('#frontdesk-form-validation').formValidation({ 
          framework: 'bootstrap', 
          fields: { 
           name: { 
            validators: { 
             notEmpty: { 
              message: 'The name is required' 
             } 
            } 
           }, 
          } 
         }) 
         .on('success.form.fv', function(e) { 
          e.preventDefault(); 
          var name = $('#first_name').val(); 
          var mobile = $('#tel1').val(); 
          var email = $('#email').val(); 
          var message = $('#message').val(); 
          var description = $('#description').val(); 
          var source = $('#source').val(); 
          var assignedTo = $('#assigned').val(); 
          $.ajax({ 
           type: "POST", 
           url: '/enquiry/add', 
           data: { 
            name: name, 
            mobile: mobile, 
            email: email, 
            message: message, 
            description: description, 
            source: source, 
            assignedTo: assignedTo 
           }, 

           success: function(data) { 
            Materialize.toast('I am a toast!', 4000); 
            return data; 
           } 
          }); 
         }); 
       } 

,这是一个更错误的IAM越来越

Uncaught TypeError: Cannot read property 'length' of undefined 
at FormValidation.Framework.Bootstrap.validateField (formValidation.min.js:10) 
at FormValidation.Framework.Bootstrap.validate (formValidation.min.js:10) 
at HTMLFormElement.<anonymous> (formValidation.min.js:10) 
at HTMLFormElement.dispatch (jquery.js:4737) 
at HTMLFormElement.elemData.handle (jquery.js:4549) 

请帮助我,在此先感谢

回答

0

Add方法后,形成第一:

$(document).on('submit', '#formid', function() { 
    $(this).validate({ 
     framework: 'bootstrap', 
     fields: { 
     name: { 
      validators: { 
      notEmpty: { 
       message: 'The name is required' 
      } 
      } 
     }, 
     email: { 
      validators: { 
      notEmpty: { 
       message: 'The email is required' 
      } 
      } 
     }, 
     mobile: { 
      validators: { 
      notEmpty: { 
       message: 'The mobile is required' 
      } 
      } 
     }, 
     } 
    }) 
    .on('success.form.fv', function(e) { 
     e.preventDefault(); 
     var Formdata = $(this).serialize(); 
     $.ajax({ 
     type: "POST", 
     url: '', //add page url here 
     data: Formdata, //send data from here, 
     success: function(data) { 
      alert(data); 
     } 
     }); 
     return false; 
    }); 
}); 
+0

感谢您的快速响应。现在我没有收到错误,但表单没有验证,直接提交 –

相关问题