必须包含http可以用str.indexOf('http')!=-1
包含正整数可以用正则/\d+/.test(str)

解决方案 »

  1.   

        if (theForm.city.value == "--请选择--"){
            alert(" 请选择 \"区域\" ,。");
            theForm.city.focus();
            return false;
        }else if (~theForm.a1.value.indexOf("http")){
            alert(" a1里面的字符必须包含http");
            theForm.a1.focus();
            return false;
        }else if (/^0$|^[1-9]\d*$/.test(theForm.a2.value)){
            alert("a2里面的必须为正整数或者0");
            theForm.a2.focus();
            return false;
        }
    注:不推荐theForm.a1.value这种不规范写法。
      

  2.   

    更正为:
    }else if (!~theForm.a1.value.indexOf("http")){