bootstrapValidator get a check and verify the status of a field is not the right questions

 In doing asynchronous file upload before uploading the file checksum verification by a single label is.

The first line below must be added, otherwise verify the results obtained is the last time after the change, bootstrapValidator not already done repeatedly checking for a field check or check mark.

$(formName).data(“bootstrapValidator”).updateStatus("fieldName",  "NOT_VALIDATED",  null );;//在之前重置某个验证字段验证规则
$("#baseForm").data('bootstrapValidator').validateField('personPicture');//触发指定字段的验证
$("#baseForm").data('bootstrapValidator').isValidField("personPicture");//获取某个标签是否验证通过过Boolean

Example:

function changepic() {
    $('#baseForm').data('bootstrapValidator').updateStatus("personPicture",  "NOT_VALIDATED",  null );
    var reads = new FileReader();
    f = document.getElementById('file').files[0];
    reads.readAsDataURL(f);
    // $("#baseForm").data('bootstrapValidator').validate();
    $("#baseForm").data('bootstrapValidator').validateField('personPicture');
    console.log($("#baseForm").data('bootstrapValidator').isValidField("personPicture"));
    if ($("#baseForm").data('bootstrapValidator').isValidField("personPicture")) {
        reads.onload = function (e) {
            document.getElementById('img').src = this.result;
            fileUpload("file");

        }
        return
    }

    layer.msg("验证不通过!");
}

 

Published 39 original articles · won praise 6 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_40155654/article/details/94862627