Jquery.validate is a powerful form verification plug-in, of course, also perfect support for Ajax validation, so that it can be convenient, fast to check the user name, etc. exist.
<form action= "" Name= "Infos" id= "Infos" >
<p> User name: <input type= "text" name= "username" id= "username"/></p>
<p><input type= "Submit" Name= "Sub"/></p>
<script type= "Text/javascript" >
$ (' #infos '). Validate ({
URL: "ajax.php",//Request address
Username:function () {return $ ("#username"). Val ();
Required: "User name must be filled in",
Remote: "User name already exists"
Submithandler:function (form) {
Alert ("Validation passed");
if ($_request[' username '] = = ' php ')
Exit ("false"); User name already exists
Exit ("true"); User name does not exist, validation passes, output "true", and End program
Note that when the server output is true or false, do not output directly, enclose in quotation marks (as shown above)