homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Need help with javascript validation

10+ Year Member

Msg#: 4551595 posted 3:46 am on Mar 6, 2013 (gmt 0)

Hello, I am having some problems getting a checkbox for terms acceptance to work.

<form name="theForm" method="post" action="updateitem.asp" onsubmit="return validate(theForm);">

Form Stuff

<table border="0" cellpadding="3" cellspacing="0" width="98%" class=fn10>
<td align=left><input type="submit" value="Update Quantity / Shipping" class="fn10">
<td align=right><input type="button" value="Continue to Checkout >>" onclick="window.location.href='getaddr.asp';" class=fn10></td>

What I want is a checkbox for "I accept the terms"

Note that there is a submit button that will cause an update of the data. The Button for continue is the one that will go to the next page.

Ideally, I would like the checkbox to remain if they click the checkbox and then the update/submit.

I'd really appreciate any guidance. I hit a mental block on this and couldn't get it after a couple of hours.





WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4551595 posted 4:16 pm on Mar 6, 2013 (gmt 0)

Something like that you should be storing server side. That is, if the user needs to agree to some terms/conditions, that agreement should be something that's saved in your database, which means you'd control the checked state of it depending on what was in the database.

If you don't want to do it that way, and you only want to add client side validation (I strongly recommend against doing it this way), then you could have a checkbox and control the checked state based on some session cookie. The has several problems though:
1. What if the user has JavaScript disabled?
2. There are probably ways around "agreeing" to the terms.
3. You won't have any stored proof that they ever agreed to any particular terms.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved