美文网首页
jquery姓名电话验证最简便方式

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

作者: 文朝明 | 来源:发表于2019-08-01 14:52 被阅读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位手机号码")
                    }
                })

相关文章

网友评论

      本文标题:jquery姓名电话验证最简便方式

      本文链接:https://www.haomeiwen.com/subject/venqdctx.html