检查表单

来源:百度知道 编辑:UC知道 时间:2024/05/14 00:05:35
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script Language="JavaScript">
var annonymous = true;

function FormCheck()
{
if (document.Form1.username.value =="")
{
alert("请填写您的用户名!");
document.Form1.username.focus();
return false;
}
if (document.Form1.password.value =="")
{
alert("请填写您的密码!");
document.Form1.password.focus();
return false;
}
if(document.Form1.cPassword.value==""){
alert("请输入您的确认密码!");
document.Form1.cPassword.focus();
return false;
}
var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
if (!filter.test(document.Form1.password.value)) {
alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于5个字符,不超过15个字符,注意不要使用空格。");
document.Form1.password.focus();

把你脚本中的Form1改成form1
把脚本中的cPassword改成cpassword
都是区分大小写的。改过来就好了

楼上正解
我也是刚测试完发现的问题

<form method="POST" action="add'.asp" name="form1" onsubmit="return FormCheck()">
改成
<form method="POST" action="add'.asp" name="Form1" onsubmit="return FormCheck()">