什么反应都没有,一闪就没有了。首先说明process.php不存在,但是不影响检验
代码如下:
<!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 language="JavaScript1.2" >
//verify_username
function verify_username(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an username .\n";
}
var illegalChars = /\w/;//allow Numbers ,letters and underscores.
if((strng.length<6)||(strng.length> 10)){
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the username contain illegal characters.\n";
}
return error;
}
//verify_passeord
function verify_password(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an Password .\n";
}
var illegalChars = /[\w_]/;//allow only Numbers ,letters .
if((strng.length<=6)||(strng.length> =10)){
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the Password contain illegal characters.\n";
}
else if (!((strng.search(/(a-z)+/))&&(strng.search(/(A-Z)+/))&&(strng.search(/(0-9)+/)))){
error = "the Password must contain at least one letter,one lowercase letter,and one Numberal.\n";
}
return error;
}
function verify_password(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an email address .\n";
}
var emailFilter =/^.+@.+\..{2,3}$/;
if(!(emailFilter.test(strng))){
error = "please enter a valid email address.\n";
}
else {
//test email for illegal character
var illegalchars=/[\(\)\<\>\,\;\;\\\"\[\]/;
if(strng.match(illegalchars)){
error = "the email address contain illegal characters.\n";
}
}
return error;
}
</script>
<title>Sample</title></head><script language="JavaScript1.2">
function check_valid(form){
var error = "";
error += verify_username(form.username.value);
error += verify_password(form.password.value);
error += verify_email(form.email.value);
if ( error !=""){
alert(error);
return false;
}
return true;
}
</script>
[/code]
<body><form action="process.php" method="post" name="test1" id="test1" onSubmit="return check_valid(this)">
<table width="100%" border="0" >
<tr>
<th width="40%" align="right" scope="col">name:</th>
<th width="60%" align="left" scope="col"><input name="username" type="text" /></th>
</tr>
<tr>
<th align="right" scope="row">password</th>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<th align="right" scope="row">Email</th>
<td ><input name="email" type="email" /></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" /></td>
</tr>
</table></form>
</body>
</html>
代码如下:
<!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 language="JavaScript1.2" >
//verify_username
function verify_username(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an username .\n";
}
var illegalChars = /\w/;//allow Numbers ,letters and underscores.
if((strng.length<6)||(strng.length> 10)){
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the username contain illegal characters.\n";
}
return error;
}
//verify_passeord
function verify_password(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an Password .\n";
}
var illegalChars = /[\w_]/;//allow only Numbers ,letters .
if((strng.length<=6)||(strng.length> =10)){
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the Password contain illegal characters.\n";
}
else if (!((strng.search(/(a-z)+/))&&(strng.search(/(A-Z)+/))&&(strng.search(/(0-9)+/)))){
error = "the Password must contain at least one letter,one lowercase letter,and one Numberal.\n";
}
return error;
}
function verify_password(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an email address .\n";
}
var emailFilter =/^.+@.+\..{2,3}$/;
if(!(emailFilter.test(strng))){
error = "please enter a valid email address.\n";
}
else {
//test email for illegal character
var illegalchars=/[\(\)\<\>\,\;\;\\\"\[\]/;
if(strng.match(illegalchars)){
error = "the email address contain illegal characters.\n";
}
}
return error;
}
</script>
<title>Sample</title></head><script language="JavaScript1.2">
function check_valid(form){
var error = "";
error += verify_username(form.username.value);
error += verify_password(form.password.value);
error += verify_email(form.email.value);
if ( error !=""){
alert(error);
return false;
}
return true;
}
</script>
[/code]
<body><form action="process.php" method="post" name="test1" id="test1" onSubmit="return check_valid(this)">
<table width="100%" border="0" >
<tr>
<th width="40%" align="right" scope="col">name:</th>
<th width="60%" align="left" scope="col"><input name="username" type="text" /></th>
</tr>
<tr>
<th align="right" scope="row">password</th>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<th align="right" scope="row">Email</th>
<td ><input name="email" type="email" /></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" /></td>
</tr>
</table></form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript1.2" >
//verify_username
function verify_username(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an username .\n";
}
var illegalChars = /\w/;//allow Numbers ,letters and underscores.
if((strng.length<6)||(strng.length> 10)){
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the username contain illegal characters.\n";
}
return error;}
//verify_passeord
function verify_password2(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an Password .\n";
}
var illegalChars = /[\w_]/;//allow only Numbers ,letters .
if((strng.length<=6)||(strng.length>=10)){//大于和等于号之间不要有空格
error = "密码不够长";
}
else if (illegalChars.test(strng)){
error = " the Password contain illegal characters.\n";
}
else if (!((strng.search(/(a-z)+/))&&(strng.search(/(A-Z)+/))&&(strng.search(/(0-9)+/)))){
error = "the Password must contain at least one letter,one lowercase letter,and one Numberal.\n";
}
return error;
}
function verify_password(strng){
var error = "";
if(strng ==""){
error = "you didn't enter an email address .\n";
}
var emailFilter =/^.+@.+\..{2,3}$/;
if(!(emailFilter.test(strng))){
error = "please enter a valid email address.\n";
}
else {
//test email for illegal character
var illegalchars=/[\(\)\<\>\,\;\;\\\"\[\]]/;//这个正则有问题 if(strng.match(illegalchars)){
error = "the email address contain illegal characters.\n";
}
}
return error;
}
</script>
<title>Sample</title></head><script language="JavaScript1.2">
function check_valid(form){
var error = "";
error += verify_username(form.username.value);
error += verify_password(form.password.value);
error += verify_email(form.email.value);
if ( error !=""){
alert(error);
return false;
}
return true;
}
</script>
<body><form action="process.php" method="post" name="test1" id="test1" onSubmit="return check_valid(this)">
<table width="100%" border="0" >
<tr>
<th width="40%" align="right" scope="col">name:</th>
<th width="60%" align="left" scope="col"><input name="username" type="text" /></th>
</tr>
<tr>
<th align="right" scope="row">password</th>
<td><input name="password" type="password" /></td>
</tr>
<tr>
<th align="right" scope="row">Email</th>
<td ><input name="email" type="email" /></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" /></td>
</tr>
</table></form>
</body>
</html>