Option button must be selected for link to work

I have some files and want to restrict the download to only users who select an option box (not checked by default). I know I can’t do this in HTML and don’t want to do it with server side programming. I am not trying that hard to restrict the download, I just want them to at least acknowledge and be aware there there are terms of agreement.

So basically, if option box checked, then link(s) can be download. If option box not checked, then files can not be downloaded (at least not with the direct link).

Yes you can :smile:

1 Like

Hmmm, well then that would be easier. HTML or JS would be good for me. Like I said, nothing to sophisticated. I just want to remind the user that there are conditions.

For modern browsers you could use the in-built error checking (required) and have the form follow the link in the action attribute.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
.submit{display:block;margin:20px 0 0}

</style>
</head>

<body>
<form name="form1" action="/linkToFiles.zip">
  <div class="download">
    <input type="checkbox" name="download" id="download" required>
    <label for="download">I Agree to Terms and Conditions</label>
     <input class="submit" type="submit" value="Click here to Download Files"></input> 
  </div>
</form>
</body>
</html>

Thanks a lot Paul. This is pretty close. What I would like to do is have 1 check box that allows access to multiple files. Would I need a form for each “link”? For example, this is what I would like:

Checkbox (Yes/No)
Link 1
Link 2
Link 3

If checkbox = Yes, then all links are available. If checkbox=no, then no links are available.

In that case you would probably be better off with my first version as you could just add more links as required by duplicating the terms box.

I’m away from my computer at the moment so can’t make a demo until tomorrow.

Sounds good. I will stand by.

I’ve updated the codepen to handle multiple links with one checkbox:

It’s pretty straight forward if you understand the check box hack so just refer to the html and css in the codepen. If anything is unclear then just ask.

Thanks very much Paul, this is excellent and has some nice features too. Great stuff!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.