I'm new to Magento and PHP as a whole but I want to set the custom option
for an input field
to
type= "number"
,
define the min
and max
number that can be allowed in the field and
throw an error if the the number is outside the min
and max
(preferably JavaScript)
However, the default custom option for input only has: the screenshot of the input type options available
Please, How do I go about this?
Try this:
<input type="number" id="qinput-<?php echo $_item->getId(); ?>" data-link="<?php echo $this->getAjaxUpdateUrl() ?>" data-item-id="<?php echo $_item->getId(); ?>" class="qty cart-item-quantity input-text input_qty" name="" min="1" value="<?php echo $this->getQty() ?>" />
This is an example of minicart input field with min=1, you can also set max for it. You don't even have to use js in this as it won't take value less than 1.