<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml
">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript">
var net="^[a-zA-z]+://[^\s]*$";
var netMsg = "输入的网址格式不正确!";
function frm_onsubmit(){
if(checkNet(document.getElementById('homepage').value,net,netMsg)){
return false;
}
}
function checkNet(objName,str,msg){
var re = new RegExp(str);
alert(str);
if(!re.test(objName)){
alert(msg);
objName.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<input type="text" style="width:200px;" name="homepage" id="homepage" />
<input type="button" value="提交" onclick="return frm_onsubmit();"/>
</body>
</html>
那个正则表达式是要有http://的