In app/design/frontend/rwd/default/template/catalog/product/view/addtocart.phtml
we can find the following code:
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = Mage::helper('core')->quoteEscape($this->__('Add to Cart')); ?>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<div class="qty-wrapper">
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<input type="text" pattern="\d*(\.\d+)?" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Qty')) ?>" class="input-text qty" />
</div>
<?php endif; ?>
<div class="add-to-cart-buttons">
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>
</div>
</div>
<?php endif; ?>
To me, these two (shortend) lines are at the moment of interest:
<input type="text" pattern="\d*(\.\d+)?" name="qty" id="qty" maxlength="12" [...] />
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)">[...]</button>
Can anyone tell me about why the button type
is set to button
rather than submit
which in return will prevent the nicely added HTML5 validation?
The main concern for my question is that I'm actually in need of HTML5 validation (or better, I'd prefer to use it over even more custom validation in my case) for some custom custom options (i.e. custom option of type number
where I'd like to use min=""
, max=""
, step=""
, ...).
When I change the button type to submit
I haven't seen any issue so far (HTML5 and the validation implemented by Magento both are working). Even though I can understand that from a design point of view it may make sense to suppress HTML5 validation, but is it actually worth it? Has anyone tried to change the button type already and can name experienced issues?