<script type= "Text/javascript" >
$ (function () {
$ ("form:input.required"). each (function () {
var $required =$ ("<strong class= ' High ' >*</strong>");
$ (this). Parent (). append ($required);
});
$ ("Form:input"). blur (function () {
var $parent =$ (this). parent ();
$parent. Find (". Formtips"). Remove ();
Verify User Name
if ($ (this). is (' #username ')) {
if (this.value== "" | | THIS.VALUE.LENGTH<6) {
var errormsg = ' Please enter a username of at least 6 bits ';
$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> ');
}else{
var okmsg= ' input is correct ';
$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> ');
}
}
Verify Mailbox
if ($ (this). is (' #email ')) {
if (this.value== "" | | (this.value!= "" &&!/[email protected]+\. [A-za-z] {2,4}$/.test (This.value))) {//regular validation of mailbox
var errormsg= "Please enter the correct e-mail";
$parent. Append (' <span class= ' formtips onError ' > ' +errormsg+ ' </span> ');
}else{
var okmsg= ' input is correct ';
$parent. Append (' <span class= ' formtips onsuccess ' > ' +okmsg+ ' </span> ');
}
}
});
//submit validation, ignoring error alerts requires a complete verification of the contents of the form.
$ (' #send '). Click (function () {
$ ("form. Required:input"). Trigger (' blur ');
var numerror=$ (' form. OnError '). Length
if (numerror) {
return false;
}
alert ("Registration is successful, password has been sent to your mailbox, please check.") ");
});
});
</script>
Form validation information jquery code