Summernote field Validator Bootstrap not validating

I am using bootstrap authentication plugin for my actual form client side and doesn't seem to work when overriding summernote textarea. It checks for the first time, but when the text is updated, the check is not updated.

Here's a validation (strips out other validation fields)

function validateEditor() {
    // Revalidate the content when its value is changed by Summernote
    $('#application-form').bootstrapValidator('revalidateField', 'application'));
};

$('.application-form')
    .bootstrapValidator({
        excluded: [':disabled'],
        fields: {
            application: {
                validators: {
                    callback: {
                        message: 'Please do not leave this blank.',
                        callback: function(value, validator) {
                            var code = $('[name="application"]').code();
                            // <p><br></p> is code generated by Summernote for empty content
                            return (code !== '' && code !== '<p><br></p>');
                        }
                    }
                }
            }
        }
    }).on('success.form.bv', function(e) {

        e.preventDefault();
        console.log('Form successfully validated.');


    })
    .find('[name="application"]')
        .summernote({
            height: 400,
            onkeyup: function() {

                validateEditor(); // Revalidate form onkeyup

            },
            onpaste: function() {

                validateEditor(); // Revalidate form on paste

            },

        });

      

Here's the markup (again paraphrased from other fields)

<div class="form-group">        

    <textarea name="application"></textarea>

</div>

      

This is a huge problem because if the text box is left blank the first time, the form can never be resubmitted since the validation is not updated when the error is corrected by the user.

+3


source to share


1 answer


I had the same problem but with FormValidation.io which is very similar to a plugin.

Solution . My textarea had an attribute required

. i removed it and bam, problem solved.



Now, I am sincerely sorry if this is not a direct solution to your problem, your code obviously has no attribute required

, but I just thought I would share with other people because it infuriated me from time to time and it was the most important post about this issue.

That's all.

0


source







All Articles