一些靠谱的表单正则验证

    

   function isInteger(obj){   
               
            reg=/^[-+]?\d+$/;    
            if(!reg.test(obj)){   
                $("#test").html("<b>Please input correct figures</b>");   
            }else{   
                $("#test").html("");   
            }   
        }   


        function isEmail(obj){   
            reg=/^\w{3,}@\w+(\.\w+)+$/;   
            if(!reg.test(obj)){        
                $("#test").html("<b>请输入正确的邮箱地址</b>");   
            }else{   
                $("#test").html("");   
            }   
        }   
        function isString(obj){   
            reg=/^[a-z,A-Z]+$/;   
            if(!reg.test(obj)){   
                $("#test").html("<b>只能输入字符</b>");   
            }else{   
                $("#test").html("");   
            }   
        }   
        function isTelephone(obj){   
            reg=/^(\d{3,4}\-)?[1-9]\d{6,7}$/;   
            if(!reg.test(obj)){   
                $("#test").html("<b>请输入正确的电话号码!</b>");   
            }else{   
                $("#test").html("");   
            }   
        }   
        function isMobile(obj){   
            reg=/^(\+\d{2,3}\-)?\d{11}$/;   
            if(!reg.test(obj)){   
                $("#test").html("请输入正确移动电话");   
            }else{   
                $("#test").html("");   
            }   
        }   
        function isUri(obj){   
            reg=/^http:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;   
            if(!reg.test(obj)){   
                $("#test").html($("#uri").val()+"请输入正确的inernet地址");   
            }else{   
                $("#test").html("");   
            }   
        } 

 

 

关于.NET技术 等其他计算机技术,欢迎加群一起讨论 3群 70536418 2群 5851499 1群 12672376

posted @ 2012-04-11 09:52  .NET技术讨论群  阅读(228)  评论(2)    收藏  举报