表单没验证完就直接提交了!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>验证网址</title>
<style type="text/css">
<!--
.style1 {font-size: 13px}
.style2 {
font-size: 12px;
color: #FF0000;
}
.style3 {font-size: 12px}
-->
</style>
</head>
<script language="javascript">
function checkURL(URL){
var str=URL;
//下面的代码中应用了转义字符"\"输出一个字符"/"
var Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
var objExp=new RegExp(Expression);
if(objExp.test(str)==true){
return true;
}else{
return false;
}
}
</script>
<script language="javascript">
function checkform1(){
var www=form1.www.value;
if(www==""){
alert("请输入个人主页地址!");
document.form1.www.focus();
}else{
if(!checkURL(www)){
alert("您输入的个人主页地址不合法!");
document.form1.www.focus();
return;
}
}
form1.submit();
}
</script>
<body>
<table width="450" border="1" cellpadding="0" cellspacing="0" background="images/sss.JPG">
<form name="form1" method="post" action="eecdss.php"> <tr align="center">
<td height="24" colspan="2" class="style1">验证网址</td>
</tr>
<tr>
<td height="20" align="center" class="style1">个人空间:</td>
<td class="style3"><input name="www" type="text" id="www" size="20" maxlength="70">
<span class="style2"> * 请输入正确的个人空间地址</span></td>
</tr>
<tr>
<td height="24" align="center"> </td>
<td class="style3"><input type="button" name="Submit" value="提交" onClick="checkform1();">
<span class="style2"> (*为必填项目)</span> <input type="reset" name="Submit2" value="重置">
</td>
</tr>
</form>
</table>
</body>
</html>