引导验证程序未进行验证
Bootstrap Validator not validating
我正在尝试使用Bootstrap Validator来验证一个表单,该表单分为两个"col md"类
第一个保持在.col-md-8内,第二个保持在.col-md-3内。
正在对.col-md-8中的进行验证,但.col-md-3中没有任何内容进行验证。
我知道Bootstrap验证器的语法是正确的,因为它是从一个正在运行的早期验证器的副本。
有人有这方面的经验吗?
<div class="form-group">
<label for="number">House Number</label>
<input class= "form-control" style="width:30%;" type="text" name="number" placeholder="e.g. 2a">
</div>
验证器javascript:
$('#multiform')
.find('[name="list_type"]')
.change(function(e) {
$('#multiform').bootstrapValidator('revalidateField', 'price');
})
.end()
.bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
required: 'fa fa-asterisk',
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
price: {
validators: {
notEmpty: {
message: 'The price is required and cannot be empty'
},
integer: {
message: 'You can only enter an integer'
},
regexp: {
regexp: /^[0-9]+$/,
message: 'The price can only consist of numbers'
}
}
},
title: {
validators:{
notEmpty: {
message:'This field cannot be empty'
},
regexp: {
regexp: /^[a-zA-Z0-9]+$/,
message: 'The title can only consist of letters and numbers'
}
}
},
desc: {
validators:{
notEmpty: {
message: 'This field cannot be empty'
},
stringLength: {
max: 500,
message: 'Your description is too long'
},
regexp: {
regexp: /^[a-zA-Z0-9#*]+$/,
message: 'The house number can only consist of letters and numbers'
}
}
},
number: {
validators:{
notEmpty: {
message: 'This field cannot be empty'
}
}
}
}
});
(对于上面的代码,它是没有验证的数字。
一切似乎都是正确的,这里有一个例子,如果你仍然遇到问题,请尽可能发布你的html。
请参见代码段。
$('#multiform')
.find('[name="list_type"]')
.change(function(e) {
$('#multiform').bootstrapValidator('revalidateField', 'price');
})
.end()
.bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
required: 'fa fa-asterisk',
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
price: {
validators: {
notEmpty: {
message: 'The price is required and cannot be empty'
},
integer: {
message: 'You can only enter an integer'
},
regexp: {
regexp: /^[0-9]+$/,
message: 'The price can only consist of numbers'
}
}
},
title: {
validators: {
notEmpty: {
message: 'This field cannot be empty'
},
regexp: {
regexp: /^[a-zA-Z0-9]+$/,
message: 'The title can only consist of letters and numbers'
}
}
},
desc: {
validators: {
notEmpty: {
message: 'This field cannot be empty'
},
stringLength: {
max: 500,
message: 'Your description is too long'
},
regexp: {
regexp: /^[a-zA-Z0-9#*]+$/,
message: 'The house number can only consist of letters and numbers'
}
}
},
number: {
validators: {
notEmpty: {
message: 'This field cannot be empty'
}
}
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/css/bootstrapvalidator.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/js/bootstrapvalidator.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form id="multiform" name="multiform" method="post">
<div class="form-group">
<label for="price">Price</label>
<input class="form-control" id="price" type="text" name="price" placeholder="e.g. 2a">
</div>
<div class="form-group">
<label for="number">House Number</label>
<input class="form-control" id="number" type="text" name="number" placeholder="e.g. 2a">
</div>
<input class="btn" type="submit" value="Send">
</form>
</div>
相关文章:
- 同一文本框中的验证程序CPF e CNPJ(ASP.NET web应用程序)
- 回发前所需的字段验证程序不起作用
- 使用xPath从Jquery数据验证程序获取输入
- 动态添加行时,启用/禁用Gridview中的验证程序
- 如何使用w3c验证程序API
- 自定义验证程序客户端验证函数未触发
- 如何为动态创建的复选框和自定义验证程序应用自定义验证
- 1000Hz 引导验证程序 data-toggle=“validator” 不起作用
- 如何使用 JQuery 确定控件是否具有必填字段验证程序
- 必需的字段验证程序在回发时触发
- 如何在使用快速验证程序注册时验证用户用户名
- 如何在引导验证程序中使用ID或CLASS而不是名称
- 禁用引导程序验证程序提交按钮,直到整个表单有效
- 如何使用引导验证程序验证输入标签列表
- 引导验证程序重置窗体
- 正在忽略验证程序
- 引导验证程序-仅部分验证
- JavaScript-引导验证程序
- 正在禁用某个字段的启动验证程序
- 如何让KendoUI验证程序忽略隐藏的表单元素