form表单提交验证bootstrapValidator

版权声明:内容记录学习过成文章,仅供参考 https://blog.csdn.net/qq_40195958/article/details/81979580

初始化表单

$('#addForm').bootstrapValidator({
	message: 'This value is not valid',
//	excluded: [":disabled"],
	feedbackIcons: {
		valid: 'glyphicon glyphicon-ok',
		invalid: 'glyphicon glyphicon-remove',
		validating: 'glyphicon glyphicon-refresh'
	},
	fields: {
		directoryCode: {
			message: '填写错误!',
			validators: {
				notEmpty: {
					message: '不能为空!'
				},
				stringLength: {
					min: 1,
					max: 100,
					message: '请控制在100字以内!'
				},
				checkEmptyChar: {
					message: '不能输入空白字符!'
				},
				//异步验证
				remote: {
		        url: 'http://xxx',
		        message: 'xxxxxx',
		        type: 'GET',
		        data: function() {
	            return {
                参数: 参数 
	            }
        },
	        success: function() {
             //处理返回值
        }
    }
			}
		}
	}
});

重置表单

$("#form").data('bootstrapValidator').resetForm();

表单返回true或false

$('#Form').data('bootstrapValidator').isValid();

表单验证调用

$('#Form').data('bootstrapValidator').validate();

猜你喜欢

转载自blog.csdn.net/qq_40195958/article/details/81979580
今日推荐