User Registration page Problem ask for directions AH

Source: Internet
Author: User
Tags rtrim
I used PHP AJAX to write a user registration page if the user name does not pass, you can not jump to the next line to enter the password how to do?


Reply to discussion (solution)

Code? Code?

Code? Code? Did I write the code? is a registration page a ajax.js a ckuser.php page that checks if a user name exists

I want to change it. If the user name does not pass, the focus has been in the user name of the input box to change how to add code?

Yes, no code, how do you know where the problem is?

I want to change it. If the user name does not pass, the focus has been in the user name of the input box to change how to add code?

If you don't pass the check, you can get the focus on the user name input box.

Yes, no code, how do you know where the problem is? Not a problem, I don't know how to add this feature


I want to change it. If the user name does not pass, the focus has been in the user name of the input box to change how to add code?

If you do not pass the verification, the user name input box to get the focus of the code change how to write ah?

Add also to the original code add, paste your code out of it.

Add also to the original code add, paste your code out of it.

reg.php
 
  
 
 
  
 <title>User Registration</title>
 
 
User name: * 3-16 characters
Password * 6-16 characters
Confirm Password: * Enter the password again

Add also to the original code add, paste your code out of it.

Ajaxlist.jsvar username_help= ' 3-16 characters (a-z,0-9,_) '; var username_ok= ' User name can be used '; The Var username_error= ' username exceeds 16 characters! '; var username_error_1= ' Your user name Input format is incorrect! '; var username_exist= ' You have filled in the user name already exists! '; var username_null= ' username is at least 3 bits long! '; function Gethttpobject () {var xmlhttp = false, if (window). XMLHttpRequest) {xmlhttp = new XMLHttpRequest (); if (Xmlhttp.overridemimetype) {xmlhttp.overridemimetype (' text/xml ');}} else{try{xmlhttp = new ActiveXObject ("Msxml2.xmlhttp");} catch (e) {try{xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");} catch (E) {xmlhttp = false;}} } return XMLHTTP; } var http = gethttpobject ();  function Getabsleft (e) {var l=e.offsetleft; while (e=e.offsetparent) L + = E.offsetleft; return l;} function Getabstop (e) { var t=e.offsettop; while (e=e.offsetparent) T + = E.offsettop; t=t+18; return t; }//...............................................................function onfouces (str) { document.getElementById (str). classname= ' Word_help '; if (str== ' Unamespan ') {document.getElementById (str). InnerHTml=username_help;}} function Backstate (str) {if (str== ' uname ') {document.getElementById (' username '). Keytype=0;document.getelementbyid ( ' Unamespan '). Classname= ' Gray ';d ocument.getelementbyid (' Unamespan '). Innerhtml=username_ok;}} function Checkusername_1 (Obj_str,num,obj_strl) {var obj=document.getelementbyid (obj_str); var obj_help= document.getElementById (Obj_strl); Obj.keytype=0;if (obj.value.length<3) {obj.keytype=1;obj_help.innerhtml= Username_null;obj_help.classname=word_error;return false;} if (obj.value.length>num) {obj.keytype=1;obj_help.innerhtml=username_error;obj_help.classname=word_error; return false;} Check if there are non-conforming characters var Name_str=obj.value; Name_str=name_str.replace (/[\u4e00-\u9fa5]/g, "); Name_str=name_str.replace (/[a-za-z0-9_]/g, "); Name_str=name_str.replace (/-/g, "); if (name_str!= ") {obj.keytype=1; obj_help.innerhtml=username_error_1; obj_help.classname=word_error; return false;} Detects if the user name exists var username = document.getElementById (' username '). Value;url = "Checkuserreg.php?username= "+username;http.open" ("GET", url,true); http.onreadystatechange = Handlehttpresponseforusername_1;http.send (null); if (obj.keytype==0) {backstate ("uname");}} function Handlehttpresponseforusername_1 () {if (http.readystate = = 4) {if (Http.status = =) {Returnstr=trim (  Http.responsetext); if (returnstr== "1") {var Obj_1=document.getelementbyid ("Unamespan"); obj_1.innerhtml=username_exist; document.getElementById ("username"). keytype=1; Obj_1.classname=word_error; return false; }}}} function Trim (str) {return RTrim (LTrim (str))} function LTrim (str) {return str.replace (/^[\t\n\r]+/g, "");}  function RTrim (str) {return str.replace (/[\t\n\r]+$/g, "");}

Add also to the original code add, paste your code out of it.

 
  0) {          echo "1";} else{          echo "0";} Mysql_close ();//Close database connection?>

Give you a train of thought, if the focus away from the judgment check does not pass, then get the focus on the line. So there is no way to enter the back.

Give you a train of thought, if the focus away from the judgment check does not pass, then get the focus on the line. So there is no way to enter the back. That's what I was thinking, but I don't know how to write the code.

Your username input box does not have an ID value, can it run successfully?

if (obj.value.length<3) {
obj.keytype=1;
Obj_help.innerhtml=username_null;
Obj_help.classname=word_error;
Obj.focus (); In addition to this sentence, the following validation is similar.
return false;
}

function Handlehttpresponseforusername_1 () {     if (http.readystate = = 4) {         if (http.status = =) {         returnstr =trim (http.responsetext);              if (returnstr== "1") {                 var Obj_1=document.getelementbyid ("Unamespan");                 Obj_1.innerhtml=username_exist;                 document.getElementById ("username"). keytype=1;                 Obj_1.classname=word_error;                 return false;             } else {               document.getElementById ("username"). focus ();//Plus this            }        }     }

function Handlehttpresponseforusername_1 () {     if (http.readystate = = 4) {         if (http.status = =) {         returnstr =trim (http.responsetext);              if (returnstr== "1") {                 var Obj_1=document.getelementbyid ("Unamespan");                 Obj_1.innerhtml=username_exist;                 document.getElementById ("username"). keytype=1;                 Obj_1.classname=word_error;                 return false;             } else {               document.getElementById ("username"). focus ();//Plus this            }        }     }
It's a matter of being able to pass, not conforming.

Your username input box does not have an ID value, can it run successfully?

if (obj.value.length<3) {
obj.keytype=1;
Obj_help.innerhtml=username_null;
Obj_help.classname=word_error;
Obj.focus (); In addition to this sentence, the following validation is similar.
return false;
This doesn't seem to work.

Oh, you're not legit (user already exists) when returning 1

function Handlehttpresponseforusername_1 () {     if (http.readystate = = 4) {         if (http.status = =) {         returnstr =trim (http.responsetext);              if (returnstr== "1") {                 var Obj_1=document.getelementbyid ("Unamespan");                 Obj_1.innerhtml=username_exist;                 document.getElementById ("username"). keytype=1;                 Obj_1.classname=word_error;                document.getElementById ("username"). focus (); Add this                return to false;}}}     

Oh, you're not legit (user already exists) when returning 1

function Handlehttpresponseforusername_1 () {     if (http.readystate = = 4) {         if (http.status = =) {         returnstr =trim (http.responsetext);              if (returnstr== "1") {                 var Obj_1=document.getelementbyid ("Unamespan");                 Obj_1.innerhtml=username_exist;                 document.getElementById ("username"). keytype=1;                 Obj_1.classname=word_error;                document.getElementById ("username"). focus (); Add this                return to false;}}}     
The master put it in the inside, it doesn't work.

In Returnstr=trim (Http.responsetext); After adding
Alert (returnstr + ': ' + returnstr.length);
See what you got.

In Returnstr=trim (Http.responsetext); After adding
Alert (returnstr + ': ' + returnstr.length);
and see what 0:1

Isn't that right?
The return is 0 to show "user name can be used"

Isn't that right?
The return is 0 to show "user name can be used" yes, but just write the code added in the inside does not work, add in the outside completely completely opposite, master brother, how to change AH

Suddenly find out that you're useful for jquery


So what are you going to do with your own writing?
I suggest you rewrite it as a straightforward example of jquery.

The digits are not available and the letters begin with
User name:3-16 characters
check.php
!--? phpecho is_numeric ($_post[' username ']{0})? 1:0;  
Isn't it easy?

suddenly find you useful jquery


So what else do you write yourself?
suggest you write a simple example of using jquery directly

 The beginning of the number is not available, the letter starts with the 
User name: 3-16 characters
check.php
!--? phpecho is_numeric ($_post[' username ']{0})? 1:0;  
Isn't it easy? OK, thanks, master.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.