jquery - JavaScript will not work with enter on form submit -
when press search button js code work. when use enter submit form bellow code not work. use of code in magento. html
<form action="<?php echo $this->geturl('storelocator/index/searchbydistance') ?>" method="get" id="search_by_distance"> <button type="button" onclick="storesearch.submit(this)"><?php echo $this->__('search') ?></button></form>
javascript
<script type="text/javascript"> //<![cdata[ storesearch.submit = function(button, url) { alert('hi'); }.bind(storesearch); //]]>
for enter keypress form submission behaviour work need have submit
button within <form>
element. current button submit form through js, change type
:
<form action="<?php echo $this->geturl('storelocator/index/searchbydistance') ?>" method="get" id="search_by_distance"> <button type="submit"><?php echo $this->__('search') ?></button> </form> <script type="text/javascript"> storesearch.submit = function(button, url) { alert('hi'); }.bind(storesearch); </script>
Comments
Post a Comment