-1

I need to click on the text "I accept the conditions of use and privacy policy", automatically check the checkbox, like this:

<label>
    <input type="checkbox" name="LOPD" id="LOPD">I accept <a href="http://www.google.es/aviso-legal/" target="blank">conditions of use</a> and <a href="http://www.google.es/politica-de-privacidad/" target="blank">privacy policy</a>
</label>

A greater, that the message div with the label "validation", in case it is not marked, appears below with the style sheets as it appears in the email field.

I have an example, in which the message comes out next to the checkbox because it is not done in another way

https://jsfiddle.net/mf0sk13e/18/

Laurent S.
  • 6,816
  • 2
  • 28
  • 40
  • You're looking for the `for` attribute on the ` – Zenoo Sep 13 '18 at 08:53
  • 1
    how is the title related to the actual question? – Lelio Faieta Sep 13 '18 at 08:57
  • Possible duplicate of [How to create an HTML checkbox with a clickable label](https://stackoverflow.com/questions/6293588/how-to-create-an-html-checkbox-with-a-clickable-label) – Laurent S. Sep 13 '18 at 09:03
  • @LaurentS. is not duplicated, because the validation div area isn't complete – Manu Terrón Sep 13 '18 at 09:10
  • Well that part is nothing but clear in your question. Not div of any kind in your example, only in the JSFiddle. it looks pretty much like another question to me, while the first part of your question is indeed a duplicate. – Laurent S. Sep 13 '18 at 09:32

1 Answers1

2

Simply add a for attribute on your <label>, its value being the id of your <checkbox> :

<label for="LOPD">
    <input type="checkbox" name="LOPD" id="LOPD">I accept <a href="http://www.google.es/aviso-legal/" target="blank">conditions of use</a> and <a href="http://www.google.es/politica-de-privacidad/" target="blank">privacy policy</a>
</label>

See the <label> documentation

Zenoo
  • 12,670
  • 4
  • 45
  • 69