请谁帮我写一个JS验证可以么非常感谢

来源:百度知道 编辑:UC知道 时间:2024/07/06 15:55:34
<html>
<head>
<meta http-equive="content-type" content="text/html; charset=gb2312">
<title>用户注册</title>
</head>
<body bgcolor="#ffcc00">
<p align="center"><b>用户注册</b>
<form action="" method="post">
<table border="1" cellspacing="0" align="center">
<tr>
<td align="right" width="135">用户名:</td>
<td width="265"><input type="text" name="username" size="22"></td>
<td width="220">由4-16个英文字母、数字或下划线组成(不支持中文、不能以数字和下划线开头)。</td>
</tr>
<tr>
<td align="right" width="135">性别:</td>
<

<html>
<head>
<meta http-equive="content-type" content="text/html; charset=gb2312">
<title>用户注册</title>
<script type="text/javascript">
<!--
function validate(){
var len; /** 公共变量 */
/** 校验用户名 */
var reg = /^[A-Za-z_]+[0-9]*$/;
var username = regForm.username.value;
if(!reg.test(username)){
alert('用户名非法!');
regForm.username.focus();
return false;
}{
len = username.length;
if(len<4 || len>16){
alert('用户名非法!');
regForm.username.focus();
return false;
}
}
/** 校验密码 */
reg = /^[A-Za-z0-9]{6,16}$/;
var password = regForm.password.value;
if(!reg.test(password)){
alert('密码非法!');
regForm.password.focus();
return false;
}
var password2 = regForm.password2.value;
if(!r