前言 |
<div class="row clearfix"><div class="col-3 t-r">电话:</div><div class="col-7"><input type="text" id="tel" name="tel" value="${invoice.tel}" onblur="checkTel()" placeholder="请输入" maxlength="30" class="input-text size-M" /></div>
</div>
注:
οnblur="checkTel()"
正则
<script type="text/javascript">var tel = $("#tel").val();function checkTel(){var tel = document.getElementById('tel').value;if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(tel)){layer.alert('电话有误,请重填');return false;}}
</script>
判断邮箱格式
if (mailaddr == null || mailaddr == "") {layer.alert('邮箱不可为空');return;}else if((!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test($('#mailaddr').val()))){layer.alert("请输入正确的邮箱格式");return ;}
判断手机号+电话
if (tel == null || tel == '') {layer.alert('请填写公司电话信息');return;}else if(!(/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$|^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$|^0\d{2,3}-?\d{7,8}$/.test($('#tel').val()))){layer.alert("请输入正确的电话号码");return ;}
小结 |