
我有一个"txtPhone“输入过滤器,它不是必须的,但只能接受电话号码,所以:
<label class="control-label">Phone</label>
<input type="text" id="txtPhone" class="form-control intonly" maxlength="12" placeholder="Phone" name="Phone">Bootstrap验证
Phone: {
validators: {
regexp: {
regexp: /^((091|\+91)?|\((091|\+91)?\)|(91)?|\(91\)|0)? ?[7-9][0-9]{9}$/,
message: 'The Indian Phone No must contain 10 digits'
},
}
},但是当我点击submit按钮时,textbox中会显示勾号。
发布于 2016-08-03 19:38:28
经过长时间的挣扎,JesusGrace我找到了答案
Bootstrap Validation
Phone: {
enabled: false,
validators: {
regexp: {
regexp: /^((091|\+91)?|\((091|\+91)?\)|(91)?|\(91\)|0)? ?[7-9][0-9]{9}$/,
message: 'The Indian Phone No must contain 10 digits'
},
}
},
.on('keyup', '[name="Phone"]', function () {
var isEmpty = $(this).val() == '';
$('#form1')
.formValidation('enableFieldValidators', 'Phone', !isEmpty);
// Revalidate the field when user start typing in the Phone field
if ($(this).val().length == 1) {
$('#form1').formValidation('validateField', 'Phone')
}
})https://stackoverflow.com/questions/38738788
复制相似问题