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
posted under Random | No Comments »

Google Analytics Tracking Code Snippet

January20

I just updated my web site pages with the new Google Analytics tracking code snippet. It fixes a rare javascript pop-up error message by using a try-catch snippet. If you are familiar with object oriented programming languages, try-catch statements are nothing new. If you aren’t familiar… well the Google article gives you everything you need to know.

For more on javascript try catch statements:
http://www.w3schools.com/jS/js_try_catch.asp

Have you updated your snippets?

posted under Random | 1 Comment »