BootstrapValidator & Ace Editor: manually updating validation status

535
November 21, 2016, at 9:06 PM

I use JQuery and BootstrapValidator 0.5.2 for form validation (at the moment I stuck with the older version). I want to validate an Ace editor field (http://ace.c9.io), it must not be empty. Validation works fine, the problem is that I cannot update the fields validation status manually. Anyone knows how can I access the bootstrap validation functions of an Ace editor field? Basically my code is as follows:

<div id="text" name="text" class="ace-editor" data-bv-field="text"></div>
$('#form').formValidation({
    fields: {
        'text': {
            validators: {
            callback: {
                // check content of ace editor
                message: 'Mandatory',
                callback: function(value, validator) {
                    var editor = ace.edit('text'),
                        ok = (editor.session.getValue() != ''),
                        status = (ok) ? 'VALID' : 'INVALID';
                    // gives error: $(...).data(...) is undefined
                    //$('#text').data('bootstrapValidator').updateStatus('text', status, null);
                    // gives error TypeError: this.options.fields[b] is undefined in bootstrapValidator.min.js
                    $('#text').bootstrapValidator().data('bootstrapValidator').updateStatus('text', status, null);
                    return ok;
                }
            }
        }
    }
});
Answer 1

This line:

$('#text').data('bootstrapValidator').updateStatus('text', status, null);

should be:

$('#form').data('bootstrapValidator').updateStatus('text', status, null);

the first parameter is supposed to be the form, not the element you are updating. Hope this helps.

READ ALSO
Sortable and hidden information through nested accordion in HTML/PHP page?

Sortable and hidden information through nested accordion in HTML/PHP page?

So i am trying to display data in sql server using PHP. I am using a sortable library i found online and this is my code:.

293
Trouble converting jpeg image to the correct byte array

Trouble converting jpeg image to the correct byte array

I was trying to send some data through a SOAP service call. Currently I am having issue to send the correct image data format(or maybe some other issues I am not aware).

329
Inserting a checkbox via jQuery stops the form to submit on webkit

Inserting a checkbox via jQuery stops the form to submit on webkit

I have a basic form with button and a checkbox inside it. The checkbox is loaded via jQuery like this:.

377
Black shadow on custom select box

Black shadow on custom select box

I am trying to use fancySelect. js in my project , FIDDLE HERE.

283