Home>

As a programmer,After solving a problem during work,It is necessary to make some conclusions,Not only is it convenient to summarize the relevant knowledge points for review,It also provides some work experience for the majority of programmers,Give peers a clear lesson.

html part:

<! Doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>formvalidator</title>
<script src="js/jquery-1.11.1.js"></script>
<script src="js/formvalidator-4.0.1.min.js"></script>
<script src="js/datetimemask.js"></script>
<script src="js/formvalidatorregex.js"></script>
<link rel="stylesheet" href="css/validator.css">
<style>
form {
width:500px;
margin:100px auto;
}
table tr td:first-child {
text-align:right;
}
table tr td {
padding:5px 0;
}
div {
margin-left:10px;
padding:0 10px;
}
</style>
</head>
<body>
<form name="myfm" action="1.html">
<table>
<tbody>
<tr>
<td><label for="uname">username:</label></td>
<td><input type="text" name="uname" /></td>
<td><div></div></td>
</tr>
<tr>
<td><label for="pwd">Password:</label></td>
<td><input type="password" name="pwd" /></td>
<td><div></div></td>
</tr>
<tr>
<td><label for="repwd">duplicate password:</label></td>
<td><input type="password" name="repwd" /></td>
<td><div></div></td>
</tr>
<tr>
<td><label>Gender:</label></td>
<td>
<input type="radio" name="sex" value="male" />
<label for="male">Male</label>
<input type="radio" name="sex" value="female" />
<label for="female">female</label>
</td>
</tr>
<tr>
<td><label for="area">Region:</label></td>
<td>
<select name="area">
<option value="0"&​​gt;-Please select-&/;/option>
<option value="1">Jinjiang District</option>
<option value="2">Taurus</option>
<option value="3">Longquanyi District</option>
<option value="4">Qingyang District</option>
</select>
</td>
</tr>
<tr>
<td><label for="num">ID:</label></td>
<td><input type="text" name="num" /></td>
<td><div></div></td>
</tr>
<tr>
<td><label for="phone">Phone number:</label></td>
<td><input type="text" name="phone" /></td>
<td><div></div></td>
</tr>
<tr>
<td><label for="email">Email:</label></td>
<td><input type="text" name="email" /></td>
<td><div></div></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="submit" /></td>
<td></td>
</tr>
</tbody>
</table>
</form>
<script>
$.formvalidator.initconfig ({//Used to configure the current formvalidator plugin
formid:"myfm",debug:false,submitonce:true,validatorgroup:"1", //Set the validator group,The default value is 1
onsuccess:function () {//Callback function after successful verification
},onerror:function () {//Callback function after validation fails
}
});
$("#uname"). formvalidator ({
validatorgroup:"1", //Validation group is 1
onempty:"The user name cannot be empty", //Prompt the user name cannot be empty
onshow:"",onfocus:"The user name must be a number or letter of 1 to 12 digits", //The form should be prompted when the form element gets focus
oncorrect:"The user name is entered correctly" //Enter the correct prompt
})
.regexvalidator ({
regexp:"^ [0-9a-za-z] {1,12} $", //Regular expression for validating form input
onerror:"The username is malformed.
Please re-enter "//Prompt for wrong input
})
.ajaxvalidator ({//Verify if the entered username already exists
datatype:"html", //The format of the requested data
async:true, //asynchronous
url:"test.php",success:function (data) {
if (data == "false") {
return false;
} else {
return true;
}
},onerror:"The username already exists.
Please re-enter ",onwait:"The validity of the username is being checked.
Please wait..."
});
$("#pwd"). formvalidator ({
validatorgroup:"1",onempty:"Password cannot be empty",onshow:"",onfocus:"Password must be 6 or more letters or numbers",oncorrect:"Password entered correctly"
})
.regexvalidator ({
regexp:"[0-9a-za-z] {6,}",onerror:"The password is malformed.
Please enter again "
});
$("#repwd"). formvalidator ({
validatorgroup:"1",onempty:"Password cannot be empty",onshow:"",onfocus:"Password must be 6 or more letters or numbers",oncorrect:"Password entered correctly"
})
.regexvalidator ({
regexp:"^ [0-9a-za-z] {6,} $",onerror:"Incorrect password format"
})
.comparevalidator ({//Compare the input content twice to the comparison symbol given below
desid:"pwd", //The id value of the compared form element
operateor:"=", //The relationship between the two elements to be compared
onerror:"The password input is inconsistent twice,Please re-enter "//Tips when the above relationship is not satisfied
});
$("#num"). formvalidator ({
validatorgroup:"1",onempty:"ID cannot be empty",onshow:"",onfocus:"Please enter your ID number",oncorrect:"Identity card format is correct"
}). regexvalidator ({
regexp:"^ [1-9] \\ d {5} [1-9] \\ d {3} ((0 \\ d) | (1 [0-2])) (([0 | 1 | 2] \\ d) | 3 [0-1]) \\ d {4} $",//15-digit ID number regular expression/^ [1-9] \ d {7} ((0 \ d) | (1 [0-2])) (([0 | 1 | 2] \ d ) | 3 [0-1]) \ d {3} $/
onerror:"Incorrect ID format.
Please enter again "
});
$("#phone"). formvalidator ({
validatorgroup:"1",onempty:"Mobile phone number cannot be empty",onshow:"",onfocus:"Please enter your mobile number",oncorrect:"Mobile phone number format is correct",})
.regexvalidator ({
regexp:"^ (0 | 86 | 17951)?(13 [0-9] | 15 [012356789] | 17 [678] | 18 [0-9] | 14 [57]) [0-9] {8} $",onerror:"The format of the mobile number is incorrect.
Please enter again "
});
$("#email"). formvalidator ({
validatorgroup:"1",onempty:"Email address cannot be empty",onshow:"",onfocus:"Please enter your email address",oncorrect:"Mailbox format is correct"
})
.regexvalidator ({
regexp:"^ \\ w + ([-+.] \\ w +) *@\\ w + ([-.] \\ w +) * \\. \\ w + ([-.] \\ w +) * $" ,onerror:"The mailbox is malformed.
Please enter again "
});
</script>
</body>
</html>
PHP part of the code:
<?php
header ("content-type:html");
$name=array ("tom", "ervin", "jhon");
$uname=$_ request ["uname"];
$notexit="true";
for ($i=0;$i<3;$i ++) {
if ($uname == $name [$i]) {
$notexit="false";
break;
} else {
}
}
echo "$notexit";
?>
  • Previous Java implements SSH mode encryption
  • Next Waterfall effect with jQuery scroll down to load content instantly