SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Audit input

Hybrid View

  1. #1
    Join Date
    Dec 2012
    0 Post(s)
    0 Thread(s)

    Audit input

    I have a question on a web page asking yes or no be checked. How do I insure the user checks yes or no?

  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    51 Post(s)
    2 Thread(s)
    Well, you can't force anyone to do anything. But you can hint strongly :P

    Sitepoint forums, if you have Javascript enabled, will bring up an annoying popup when you click "log out" (with the message "are you SURE you want to log out? Or were you hitting that button just for fun?"). Users must click away the alert dialog before the browser allows access to the other browser controls, and before the browser will continue allowing the user to leave the current page.

    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!">
    You can either keep it a GET and use Javascript validation to bring an error/annoying popup instead of letting the form "submit" (with a GET, the form will pretty much just act like an HTML anchor),
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts