//正则验证手机号码
function isPhoneNum(value){
	return /^1[345678]\d{9}$/.test(value);
};
//正则验证邮箱
function isEmail(value){
	return /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(value);
}

 Js正则表达式数字或者带小数点的数字

function chk() {
            var patrn = /^\d+(\.\d+)?$/;
            var result = true;
            $("input[type=text]").each(function () {
                if (!patrn.exec(this.value)) {
                    alert("请输入正确的数字!");
                    result = false;
                }
            })

            return result;
        }

注册页面发送验证码

var countdown=60;
    function settime(val) {
        if (countdown == 0) {
            val.removeAttribute("disabled");
            val.value="发送验证码";
            countdown = 60;
        }else {
            val.setAttribute("disabled", true);
            val.value="重新发送(" + countdown + ")";
            countdown--;
            setTimeout(function() {
                settime(val)
            },1000)
        }
    }

 

posted on 2018-05-18 15:07  jessie912  阅读(97)  评论(0编辑  收藏  举报