function checkInput(){
$("[inputCheckType='Email']").blur(function (event) {
var email=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
if(!email.test($(this).val())){
/* $(this).removeClass("form-control"); */
$(this).css("border","1px solid #E74C3C");
}
});
$("[inputCheckType='Tel']").blur(function (event) { // // 座机|手机
var phone=/(^(?:(?:0d{2,3})-)?(?:d{7,8})(-(?:d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
if(!phone.test($(this).val())){
$(this).css("border","1px solid #E74C3C");
}
});
$("[inputCheckType='Idno']").blur(function (event) {
var idno = /(^d{15}$)|(^d{18}$)|(^d{17}(d|X|x)$)/;
if(!idno.test($(this).val())){
$(this).css("border","1px solid #E74C3C");
}
});
}
==============初始时调用checkInput()方法==============
$(document).ready(function() {
checkInput();
});
==============页面直接赋值==============
<div class="col-sm-2">
<input type="text" inputCheckType='Idno' id="CardNo" name="CardNo" readonly="readonly" class="form-control" >
</div>