mardi 15 mars 2016

javascript code for required checkbox

I have a website and I'm trying to make my (extra cost) checkboxes required before proceeding to checkout with paypal. The checkboxes, when clicked, add extra money to the total price as well (not sure if that affects anything). I also cannot find the name= field for the checkboxes so I used id= which I'm sure is completely wrong. Sorry I am extremely new with this.

CODE:

<input class="package-check-js id-option-js-44" id="package-44" data-option_id="44" data-id="186" data-pricing="50" data-daily="0" data-days="3" value="add" type="checkbox">

SUBMIT PAYPAL CODE:

<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="Proceed to PayPal" data-value="Place order">

CUSTOM CSS:

<form action="../" onsubmit="if (this.package-44.checked == false) { alert ('You didn\'t choose any of the checkboxes!'); return false; } else { return true; }">
<p><input type="checkbox" id="package-44" value="add"></p>
<p><input type="submit" name="woocommerce_checkout_place_order" value="Proceed to PayPal"></p>

I would like this in javascript form.




Aucun commentaire:

Enregistrer un commentaire