1

在将 Jquery 变量调用到 Bootstrap 验证器时面临问题。声明了一个变量 tempValue 以及在我的自定义函数中使用该变量的语法 2

$(document).ready(function () {
     var tempValue = $('#firstName').val();
$('#registration').bootstrapValidator({
    feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
        firstName: {
            validators: {
                stringLength: {
                    min: 1,
                    max: 50,
                    message: 'First name cannot exceed 50 characters'
                },
                notEmpty: {
                    message: 'Please enter your first name'
                },
                customFunction1: {
                    keyValue: customFunction2(tempValue)
                }
            }
        });
    }); 
4

0 回答 0