1 <!--use JS to verify the user's registration information locally, common password settings are too short, the user name is too long, and so on.2 for safety and reliability, it is best to perform two validations on the server. My server language is PHP. 3 local authentication can reduce requests to the server (Novice awareness ~). The following is the specific code,4 -5 <!DOCTYPE HTML>6 <HTML>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />8 <Head>9 <title>User Register Page</title>Ten </Head> One <Body> A <Script> - functionCheckusername () { - varobj=Document.reg_form.user_name.value; the if(Obj.length> 6) { - Alert ("user name length exceeds limit! "); - return false; - } + varv_pwd=Document.reg_form.pwd.value; - if(V_pwd.length> Ten) { + Alert ("password length exceeds limit! "); A return false; at }Else if(V_pwd.length< 5) { - Alert ("The password is too short! "); - return false; - } - return true; - } in </Script> - <formname= "Reg_form"Action= "server_register_verify.php"Method= "POST"onsubmit= "return Checkusername ()"> to <P>User name:<inputtype= "text"name= "user_name" /></P> + <P>Password:<inputtype= "Password"name= "pwd" /></P> - <P>Confirm Password:<inputtype= "Password"name= "Pwd_again" /></P> the <P><inputtype= "Submit" /></P> * </form> $ </Body>Panax Notoginseng </HTML>
JavaScript Local Authentication User registration information