我使用BootstrapValidator和我有一些文本字段和2个选项的单选按钮,我需要验证文本字段只有在单选按钮选项2被选中,我怎样才能获得呢?BootstrapValidator条件验证
这是形式:
<form action="/it/Account/SignUp" class="form-horizontal" id="signup_form" method="post" role="form">
<label>Name</label>
<input type="text" name="name" class="form-control" id="name">
<label>Company</label>
<input type="text" name="company" class="form-control" id="company">
<input type="radio" name="usertype" value="0"><label>Private</label>
<input type="radio" name="usertype" value="1"><label>Company</label>
</form>
这是JavaScript的BootstrapValidator:
$('#signup_form').bootstrapValidator({
message: 'This value is not valid',
live: 'disabled',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
validators: {
notEmpty: {
message: 'required'
},
}
},
company: {
validators: {
notEmpty: {
message: 'required'
},
}
},
}
}
我只需要确认“公司”字段仅当“用户类型”的无线电值等于1
守则,请... – nicael
欢迎来到Stack Overflow。请提供一个你迄今为止尝试过的例子,以及你遇到的问题?如果您可以证明您在发布之前试图解决问题,那么您很可能会收到社区的有用回复。 –
我插入了一个代码示例 – user2100125