【www.gdgbn.com--php常用代码】

网页特效邮箱 网址正则验证代码
 
    function checkurl(){
        var maxlength = 50;
        var url = $("#tbcommentauthorurl").val();
       
        if(url.length == 0){
            commenturlisvalid = true;
            return true;
        }
        else if(url.length > maxlength){
            $("#tip_url").html("主页地址不允许超过" + maxlength + "个字符!");
            commenturlisvalid = false;
            return false;
        }
        else if(url.indexof("http://")!=0 || url.indexof(".") < 0){
            $("#tip_url").html("主页地址要以“http://”开头");
            commenturlisvalid = false;
            return false;
        }
        else{
            $("#tip_url").html("");
            commenturlisvalid = true;
            return true;
        }
   }
  
   function checkemail(){
        var email = $("#tbcommentemail").val();
        if(email.length>0){
            var regexp = new regexp("w+@((w|-)+.)+[a-z]{2,3}");
            if(!regexp.test(email)){
                $("#tip_email").html("请输入正确的邮件地址!");
                commentemailisvalid = false;
            }
            else{
                commentemailisvalid = true;
                 $("#tip_email").html("");
            }
        }
        else{
            commentemailisvalid = true;
            $("#tip_email").html(""); 
        }
   }
  

本文来源:http://www.gdgbn.com/jiaocheng/29165/