jquery姓名电话验证最简便方式

2019-08-01  本文已影响0人  文朝明
 $('#name').focus(function() {
                    if ($(this).val() == "请输入证件上的真实姓名") {
                        $(this).val("")
                    }
                })
                $('#phone').focus(function() {
                    if (!(
                            /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/
                        ).test($(this).val())) {
                        $(this).val("")
                    }
                })
                $('#name').blur(function() {
                    if ($(this).val() == "" || $(this).val() == undefined || $(this).val() == null) {
                        $(this).val("请输入证件上的真实姓名")
                    }
                })
                $('#phone').blur(function() {
                    if ($(this).val() == "" || $(this).val() == undefined || $(this).val() ==
                        null) {
                        $(this).val("接受确认短信及使用提醒")
                    } else if (!(
                            /^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/
                        ).test($(this).val())) {
                        $(this).val("请正确输入11位手机号码")
                    }
                })
上一篇 下一篇

猜你喜欢

热点阅读