Matthew Steven Kelly

Agree To Terms Validation

February5

Every so often I need a simple script to validate an “agree to terms” check box for an HTML form. Here is a simple script I came up with to perform that validation using javascript:

The code:

<script type=”text/javascript”>
<!– 
function checkValues(form)
{
  if ( form.terms.checked == false )
  {
    alert("You must check the AGREE TO TERMS AND PRICING box.");
    return false;
  }
  form.submit();
}
–>
</script>
<br><form name="pricingterms" action="validation.html" method=post>
<div class="msg_head”><input type="checkbox" name="terms" value="Yes" />AGREE TO PRICING AND TERMS</div>
<br><input type="button" name="SubmitButton" value="Register It Now" onclick="checkValues(this.form)" />
</form>

And a form to test with:

License Agreement Validation Form

AGREE TO PRICING AND TERMS
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
posted under Random

Email will not be published

Website example

Your Comment: