将Jquery字段值传递给Bootstrap Validator

时间:2017-06-12 16:41:23

标签: jquery twitter-bootstrap twitter-bootstrap-3 bootstrapvalidator

面对将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)
                }
            }
        });
    }); 

0 个答案:

没有答案