dimanche 22 janvier 2017

Submit Form Only When Checkbox is Checked

For a similar to the following example code, how can I do the following when the user hits submit, using Jquery 1) check if the checkbox is checked. -If yes, submit the form. - If not, show an alert "Please check the box before submitting the form", cancel form submission. 2) After, when the checkbox is checked form can be submitted.

<html>
    <form>
        <input type="checkbox" name="chbox" id="chbox">Check this box before submission 
        <br>
        <input type="submit" value="submit" id="submit">
    </form>
  </html>



Aucun commentaire:

Enregistrer un commentaire