Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery formvalidation uncaught range error : maximum call stack size exceeded

I am trying to use Jquery form validation. But i am getting the Uncaught range error : maximum call stack exceeded.i am using materialize css.

this is the error i am getting

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)

This is my jquery and html code

 <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>
SUBMIT
        </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;
                                }
                            });
                        });
                }

and this is the one more error iam getting

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)

Please help me, Thanks in advance

like image 277
Jayanthkumar S Avatar asked May 19 '26 16:05

Jayanthkumar S


1 Answers

I am getting the same error and after searching a lot. I found that I forgot to add a class form-group at the parent container of the element which we are validating and now its working fine for me.

like image 131
dom Avatar answered May 22 '26 04:05

dom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!