Copy CodeThe code is as follows:
<title>Form</title>
Copy CodeThe code is as follows:
function Form_sub ()
{
if (!test_username (Document.form1.username.value))
{
Alert ("Incorrect name format");
return false;
}
if (!test_date (Document.form1.birthday.value))
{
Alert ("date format is incorrect");
return false;
}
if (!test_email (Document.form1.email.value))
{
Alert ("e-mail address format is incorrect");
return false;
}
if (!test_password (Document.form1.password.value, Document.form1.password2.value))
{
Alert ("Two times password input is not the same");
return false;
}
}
function Test_username (str_username)
{
var pattern =/[a-za-z_]/;
if (Pattern.test (str_username))
return true;
Else
return false;
}
function Test_date (str_birthday)
{
var pattern =/[0-9]{4}-[0-9]{2}-[0-9]{2}/;
if (Pattern.test (Str_birthday))
return true;
Else
return false;
}
function Test_email (str_email)
{
var pattern =/^[a-za-z0-9_.] +@ ([a-za-z0-9_]+.) +[a-za-z]{2,3}$/;
if (Pattern.test (Str_email))
return true;
Else
return false;
}
function Test_password (STR_P1, STR_P2)
{
if (STR_P1==STR_P2)
return true;
Else
return false;
}
Copy CodeThe code is as follows:
This program is used to receive form data from an HTML page and to validate it accordingly
$founderr = false; Initialize the FOUNDERR variable to indicate no error
if (!ereg ("[A-za-z_]", $_get[' username ']))
{
echo "name format is incorrect
";
$founderr = true;
}
if (!ereg ("[0-9]{4}-[0-9]{2}-[0-9]{2}", $_get[' birthday ']))
{
echo "date format is incorrect
";
$founderr = true;
}
if (!ereg ("^[a-za-z0-9_.") +@ ([a-za-z0-9_]+.) +[a-za-z]{2,3}$ ", $_get[' email '))
{
echo "e-mail address is not properly formatted
";
$founderr = true;
}
if ($_get[' password ']! = $_get[' Password2 '])
{
echo "Two times password input is not the same";
$founderr = true;
}
if (! $founderr)
{
?>
<title>Form</title>
| Name: |
|
| Password: |
|
| Gender: |
|
| Birthday: |
|
| E-Mail: |
|
| Occupational: |
|
}
?>
http://www.bkjia.com/PHPjc/319920.html www.bkjia.com true http://www.bkjia.com/PHPjc/319920.html techarticle Copy the code code as follows: HTML head titleform/title meta http-equiv= "Content-type" content= "text/html; charset=gb2312" script language= "JavaScript" src= "Form.js" src= "Form.js"/scr ...