JavaScript check for checkboxes, error hints and button discoloration actions

Source: Internet
Author: User

Agree to the relevant terms when not ticked, the login button is gray and cannot be submitted, click the gray Sign-in button to agree to the relevant terms, tick and turn into bright light and can submit information.

check box and text:

1 <div class= "Check-rule" >2     <label>3         <input type= "checkbox" Name = "id=" check "class=" hidden "onchange=" Boxchange (This) ">4         <i class=" Check "></i>5      </label>6         I agree to the relevant terms <span ><font  id= "agreerule" color= "Red" size= "3" > </font></span>7 </div>
JS Code button Color Realization:
functionBoxchange (obj) {if($ (obj). Prop ("Checked")){            //Check Action            varNewbtn=document.getelementbyid ("Regist"). src= ". /resources/img/regist-btn.png "; $("#regist"). CSS ("Background", ' url (' + newbtn + ') '); $("#agreeRule"). Hide (); }Else{            //Uncheck Action            varNewbtn=document.getelementbyid ("Regist"). src= ". /resources/img/regist-btngray1.png "; $("#regist"). CSS ("Background", ' url (' + newbtn + ') '); document.getElementById ("Agreerule"). Innerhtml= "Please agree to the relevant terms"; $("#agreeRule"). Show (); }    }
The JS code determines if the checkbox is selected:
function Verify () {        var ischeck=$ ("#check"). Get (0). checked;   Gets the selected state, which returns TRUE or False         if(!  Ischeck) {            document.getElementById ("Agreerule"). Innerhtml= "Please agree to the relevant terms";              return ;         } Else {//         Related actions ...     }



JavaScript check for checkboxes, error hints and button discoloration actions

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.