Default enter key on button using jquery

Write the following script for set the default enter key:

<script language="javascript">
    $(document).ready(function () {
        $("input").bind("keydown", function (event) {
            var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
            if (keycode == 13) {
                document.getElementById('SubmitButton').click();
                return false;
            } else {
                return true;
            }
        });
    });
</script>

 

<input id="InputSearch1" type="text" onblur="if(this.value=='')this.value=this.defaultValue;"
onfocus="if(this.value==this.defaultValue)this.value='';" value="search"/>

<input type="button" id="SubmitButton" />

 

Ebook Download
View all
Learn
View all