Accept Terms & Condition Script in JS


On any site, while registering we accept terms and conditions. In this tutorial we are going to see how to implement accept terms and condition logic in your webpage using JavaScript.
Accept-Terms-and-Conditions-JS-Code


[box]Download Code Live Demo[/box]

JavaScript Code :

First of all we need to put following JS code in the head section of the HTML.

Now we need to call the above JS code on the button click event. Put below form code in the body section of HTML -

Code Explanation :

We have -

Parameter Use
success.html This page will be rendered when user successfully accepts terms and conditions.
validate(this) This method will be called to check whether the check box is checked or not.

In the JS code following statement will provide us the checked value of the Check Box -