I have a question on a web page asking yes or no be checked. How do I insure the user checks yes or no?
Well, you can't force anyone to do anything. But you can hint strongly
So an annoying alert() popup is one option (to remind people... first time they click, their action is cancelled and they get a popup. Next time they click, they get through. Or be really evil and keep giving them popups until they make a choice).
If this is a form, or a gateway page to more pages, you can use the form. Whatever users are clicking to get to your next page, you can prevent access to your next page with form validation.
<p>Please choose yes or no before preceding to the next page:</p>
<form action="nexturlpeoplewanttogoto" method="get">
<input type="checkbox" id="yes" name="yes" value="1"><label for="yes"> Yes</label><br>
<input type="checkbox" id="no" name="no" value="2"><label for="no"> No</label>
<input type="submit" value="To The Next Page!">
or you can change to POST and have the backend either
-send out a validation error on the same page, or
-send the user a url to the next page (let them pass through)
There are other ways (evil back-button-breaking new target/iframes for example) but these are the first ones that come to my mind. It kinda depends on why users must choose one of these things.
None of the above techniques would prevent a user from just leaving your site or going anywhere else. This only really works when both the page they are on and the page they want to go to are both yours.
This topic is now closed. New replies are no longer allowed.