jquery验证网址输入

        function IsURL() {
            var str_url = jQuery.trim($("[name$='txtlink']").val());
            if (str_url != "") {
                var strRegex = /(^([w]{3}\.))+[a-z0-9_-]+\.[com|cn]/ig;
                var re = new RegExp(strRegex);
                if (!re.test(str_url)) {
                    ShowError("link", "提示:请你填写www.chuju.com格式的url");
                    return false;

                }
                else {
                    NoneError("link");
                    return true;
                }
            } else {
                NoneError("link");
                return true;

            }

        }

只能是www.XXx.com/cn这种类型的网址

posted @ 2010-12-16 23:01  rains  阅读(383)  评论(0编辑  收藏  举报