<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script src= "Jquery.min.js" ></script>
<script>
$ (function () {
$ ("#userEmail"). blur (function () {
var re =/^\[email protected]\w+ (\.\w+) {1,3}$/;
if ($ (this). Parent (). FIND ("span"). Length > 0) {
$ (this). Parent (). FIND ("span"). Remove ();
}
if (Re.test (this). Val ())) {
$ (this). After ("<span class= ' OK ' >ok</span>");
}else {
$ (this). After ("<span class= ' ERROR ' > your registered email is not standard!) </span> ");
}
});
$ ("#pwd"). blur (function () {
var re =/\w{6,20}$/;
if ($ (this). Parent (). FIND ("span"). Length > 0) {
$ (this). Parent (). FIND ("span"). Remove ();
}
if (Re.test (this). Val ())) {
$ (this). After ("<span class= ' OK ' >ok</span>");
}else {
$ (this). After ("<span class= ' error ' >error</span>");
}
});
$ ("#reg: Submit"). Click (function () {
$ ("#userEmail"). Triggerhandler ("blur");
$ ("#pwd"). Triggerhandler ("blur");
if ($ ("#reg"). Find (". Error"). Length > 0) {
return false;
}
});
});
</script>
<style>
. OK {
Color:green;
}
. Error {
color:red;
}
</style>
<body>
<form action= "http://www.baidu.com" id= "Reg" >
<p>
Mailbox:
<input type= "text" name= "UserEmail" id= "UserEmail" >
</p>
<p>
Password:
<input type= "password" name= "pwd" id= "pwd" >
</p>
<p>
<input type= "Submit" value= "Registration" >
</p>
</form>
</body>
Front-End Mailbox verification