版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
1.页面编写:
<td align="right" class="pc_jzxx_xx_td">
<font color="#d44031">*</font>
<span class="pc_jzxx_xx_strong">手机号 : </span>
</td>
<td align="left">
<input type="text" autocomplete="off" id="phone" class="pc_jzxx_left_input" name="phone" validate="" title="手机号为11位!" οnblur="checkPhone()"/>
<img src="../jzxx_img/ts_sb_icon.png" class="pc_jzxx_xx_sb" id="pc_jzxx_xx_sb"/>
<img src="../jzxx_img/ts_cg_icon.png" class="pc_jzxx_xx_cg" id="pc_jzxx_xx_cg"/>
<img src="../jzxx_img/ts_fx_icon.png" class="pc_jzxx_xx_fx" id="pc_jzxx_xx_fx"/>
</td>
2.判断手机号是否正确的方法
//判断手机号
function checkPhone(){
var phone = document.getElementById('phone').value;
if(!(/^1[3456789]\d{9}$/.test(phone))){
$("#pc_jzxx_xx_sb").show();
$("#pc_jzxx_xx_cg").hide();
document.getElementById("phone").style.border='1px solid #d44031';
return false;
}else{
$("#pc_jzxx_xx_cg").show();
$("#pc_jzxx_xx_sb").hide();
document.getElementById("phone").style.border='1px solid #e5e5e5';
}
}