Shopify Drop down Validation

Solved
New Member
1 0 0

I'm building a web store on shopify. I want to add a validation to dropdown that if no size/value is selected from drop down, it automatically select 1st size/value. when we click on add to cart button.

0 Likes
Highlighted

Success.

Shopify Expert
175 34 56

<select id="drop">
   <option value="0">Please select</option>
   <option value="1">One</option>
   <option value="2">Two</option>
   <option value="3">Three</option>
</select>
<button id="add">Add to cart</button>
Use this javascript/jQuery:$(document).ready(function() {
   var $drop = $("#drop");
   $("#add").on("click", function() {
       if($drop.val() == 0) {
           $drop.val(1);
       }
   });
});

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza
1 Like