Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何禁用搜索栏上的enter键_Javascript_Php_Magento - Fatal编程技术网

Javascript 如何禁用搜索栏上的enter键

Javascript 如何禁用搜索栏上的enter键,javascript,php,magento,Javascript,Php,Magento,我正在使用Magento,希望禁用搜索栏上的enter键。我的搜索栏代码如下: <form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get"> <div class="input-box"> <label for="search"><?php echo $this->_

我正在使用Magento,希望禁用搜索栏上的enter键。我的搜索栏代码如下:

<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
    <div class="input-box">
        <label for="search"><?php echo $this->__('Search:') ?></label>
        <input id="search" type="search" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="input-text required-entry" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" placeholder="<?php echo $this->quoteEscape($this->__('Search entire store here...')) ?>" />
        <button type="submit" title="<?php echo $this->quoteEscape($this->__('Search')) ?>" class="button search-button"><span><span><?php echo $this->__('Search') ?></span></span></button>
    </div>

    <div id="search_autocomplete" class="search-autocomplete"></div>
    <script type="text/javascript">
    //<![CDATA[
        var searchForm = new Varien.searchForm('search_mini_form', 'search', '');
        searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
    //]]>
    </script>
</form>
使用:

将其放在模块的layout.xml中的defaul标记下:

<layout>  
    <default>
        <reference name="head">
            <action method="addJs">
                <script>custom.js</script>
            </action>
        </reference>
    </default>
</layout>

custom.js
使用:

将其放在模块的layout.xml中的defaul标记下:

<layout>  
    <default>
        <reference name="head">
            <action method="addJs">
                <script>custom.js</script>
            </action>
        </reference>
    </default>
</layout>

custom.js

在react中,您可以禁用表单提交

<form id="dashboard-form" onSubmit={(e)=> e.preventDefault()}></form>
e.preventDefault()}>

在react中,您可以禁用表单提交

<form id="dashboard-form" onSubmit={(e)=> e.preventDefault()}></form>
e.preventDefault()}>

这并不容易,这取决于magento版本和您的环境设置,但这应该会有所帮助。这也可能会帮助您找到答案-这并不容易,取决于magento版本和您的环境设置,但这应该会有所帮助。这也可能会帮助您找到答案-