I work with magento, on the item page there is an input for entering the quantity of the item. What do I want? I want that when you enter numbers and click on Enter, it does not react to the action, but only when you click on the "Add to cart" button. Why is that? Because it is not clear where to redirect. How to make so that input would not react to Enter?
2 answers
You just need to catch the Enter event and do nothing at the same time.
$("#id_of_input").keyup(function(event){ if(event.keyCode == 13){ event.preventDefault(); } }); You can even read in English. site - link
- the idea is good, but it doesn’t work for me) - urbanlol
|
The answer came suddenly.
<?php if(!$_product->isGrouped()): ?> <span class="number-mark"> <input id="qty" class="input-text qty" title="<?php echo $this->__('Qty') ?>" maxlength="12" name="qty" type="text" value="1" /> </span> <?php endif; ?> and here is the necessary script
<script> document.getElementById("qty").onkeypress= function(event){ event= event || window.event; if (event.charCode && (event.charCode < 48 || event.charCode > 57))// проверка на event.charCode - чтобы пользователь мог нажать backspace, enter, стрелочку назад... return false; }; 8 </script> |