This afternoon I studied jquery and made a simple user name check program to check whether the current user name already exists. Contains 4 files: jquery-1.4.jscheck.jscheck.htmlcheck.php
This afternoon I studied jquery and made a simple user name check program to check whether the current user name already exists.
Contains 4 files: jquery-1.4.js check. js check.html check. php
Where the jquery-1.4.js is JQuery code, you can download Oh. Check. js is a self-written file for verification.
The code is as follows:
- // Check. js
- $ (Document). ready (function (){
- $ ("# Username"). blur (function (){
- Var username = $ (this). val ();
- Var url = "check. php ";
- $. Post (url, {name: username}, function (str ){
- If (str = '1 '){
- $ ("# Info" ).html ("registered ");
- } Else {
- $ ("# Info" ).html ("registered ");
- }
- });
- });
- });
- // Check. php
- // Tianya PHP blog http://blog.phpha.com
- If (isset ($ _ POST ['name']) {
- $ Username = trim ($ _ POST ['name']);
- // Test only (database not queried). assume that the user name admin is registered.
- If ($ username = 'admin '){
- Exit ('1 ');
- }
- Exit ('0 ');
- }
- ?>
- // Check.html
- Script