IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

Set ENTER key to submit Form using jQuery

This is based on a project using a ASP.NET Web Forms search page with a textbox txtSearchID and a search button btnSearch. The request was to make the submit button enabled by default when a user pressed on the ENTER key.

<asp:TextBox ID="txtSearchID" runat="server" MaxLength="10" />
<asp:Button ID="btnSearch" runat="server" Text="Search" />

The quickest solution is by adding a jQuery snippet at the end of the HTML doc, just before the closing </body> tag:

<script>
$(document).keypress(function(e) {
	if (e.keyCode === 13) {
		$("#<%= btnSearch.ClientID %>").click();
		return false;
	}
});
</script>

July 22, 2014 Filed Under: How To Tagged With: ASP.NET, jQuery

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure