JS Summary Summary (later all collected in this article)

Source: Internet
Author: User

  point 1:js in the comparison string is equal, JS in the "= =" to determine whether the equality , this is not the same as in Java, Java is. Equals () This method.

In the previously written Ajax demo, because of the use of. Equals () to compare two passwords are equal, for a long time did not find the reason. So remember that js is "= =" instead of the. Equals () method.

Instance:

  

<script type= "Text/javascript" >function Checkpassword () {var pass1 = document.getElementById ("Passwod"). Value; var pass2 = document.getElementById ("Confirm"). Value;alert ("Pass1:" +pass1+ ", Pass2:" +pass2 "); PASS1==PASS2)) {//can be compared normally,  //used before! Pass1.equals (PASS2)), depressed for a long time only to find that this is not the same as in Java alert ("Jinlai");d Ocument.getelementbyid ("Confirm"). Innerhtml= "Password inconsistent, Please confirm and re-enter the ";d Ocument.getelementbyid (" name "). focus ();//relocate to the Account entry Section}}</script>

  

The corresponding HTML code is as follows:

<body>name:<input type= "text" id= "name" Name= "UserName" onblur= "CheckName ()"/><span id= "Span1" class= "S1" ></span></br>password:<input type= "password" name= "password" id= "password"/></br> Confirm: <input type= "password" id= "confirm" onblur= "Checkpassword ()"/><span id= "span2" class= "S1" ></ Span></body>

  

JS Summary Summary (later all collected in this 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.