Thursday, July 9, 2015

submit form on Enter key not working with IE

IE (Internet Explorer) behaving weird while submitting form with 'Enter' key instead of clicking on submit button.

If you have one text input and one submit button in form, the IE will disable 'submit' on pressing 'Enter' key.

Solution : 

Please add one more extra hidden field in form to make it working.

This won't work : 

                    <form method="post">
                        <span class="inputs-group">
                        <label>Search for</label>
                        <input class="input-text input-100" autocomplete="off" type="text" name="keywords" value=""  />
                        </span>
                        <input type="submit" name="submit" class="go" value="Go"/>

                    </form>


This will work :

                    <form method="post">
                        <div style="display:none">                 
                        <input type="text" name="hiddenText"/>     
                        </div>
                        <span class="inputs-group">
                        <label>Search for</label>
                        <input class="input-text input-100" autocomplete="off" type="text" name="keywords" value=""  />
                        </span>
                        <input type="submit" name="submit" class="go" value="Go"/>

                    </form>