Change the password and verify that the two inputs are the same.

Source: Internet
Author: User

JS Code

1 <SCRIPT type = "text/JavaScript"> 2 3 4 // enter the password for the first time, and the focus event 5 function check2pwd1 () is lost () {6 // obtain the first entered password 7 var newpwd1 =$ ("# newpwd1 "). val (); 8 9 // obtain the password 10 var newpwd2 = $ ("# newpwd2") for the second input "). val (); 11 // check whether the password is valid again. If yes, check 12 if (newpwd2! = NULL & newpwd2.length> 0) {13 return check2pwd2 (); 14} 15 16 return false; 17} 18 // when you enter the password for the second time, the loss of focus triggers this method 19 function check2pwd2 () {20 21 // obtain the first entered password 22 var newpwd1 =$ ("# newpwd1 "). val (); 23 24 // get the second password 25 var newpwd2 =$ ("# newpwd2 "). val (); 26 27 // get the prompt message span28 var span =$ ("# newpwd2span"); 29 // determine if the same 30 if (newpwd1 = newpwd2) {31 32 span.html ("two inputs are consistent"); 33 return true; 34} else {35 span.html ("two inputs are inconsistent, please enter again "); 36 return false; 37} 38} 39 40 41 // total verification, 42 function checkall () {43 var A = check2pwd1 () when submitting the form (); 44 var B = check2pwd2 (); 45 return a & B; 46} 47 48 </SCRIPT>
View code

 

HTML code (Nice validator plug-in verification is included)

 

<Form action = "<% = request. getcontextpath () %>/master/sysuser_updatesysuserpwd.action "method =" Post "onsubmit =" Return checkall (); "data-validator-option =" {theme: 'Yellow _ right_effect ', stoponerror: true} "id =" updateform "> <ul class =" forminfo "> <input type =" hidden "name =" sysuserid "value =" $ {sysuser. sysuserid} "> <li> <label> User Name <B> * </B> </label> <input name =" sysusername "type =" text "class =" dfinput" value = "$ {sysuser. sysusername} "readonly =" readonly "/> </LI> <li> <label> New Password <B> * </B> </label> <input id =" newpwd1 "Name =" sysuserpass "type =" password "class =" dfinput "data-Rule =" new password: required; password; "/> </LI> <li> <label> enter the password again <B> * </B> </label> <input id =" newpwd2 "type =" password" class = "dfinput" data-Rule = "re-enter the password: required; match (sysuserpass); "/> <span id =" newpwd2span "> </span> </LI> <li> <label> & nbsp; </label> <input name = "" type = "Submit" class = "BTN" value = "Confirm modification"/> & nbsp; <input name = "" type = "reset" class = "BTN" value = "Reset information">
View code

 

 

 

 

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.