Hi all,
May i know, how to run function when user press ENTER button after they key-in some value on textbox?
Condition:
User keyin Employee No on textbox and press ENTER button. System will run the function.
Thanks
Hi asrul,
Check the below code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(function () { var txtName = $('[id *= txtName]'); $(txtName).keypress(function (event) { var keyCode = event.keyCode; if (keyCode == 13) { alert('You have entered employee no - ' + txtName.val()); txtName.val(''); event.preventDefault(); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <input name="txtName" type="text" id="txtName" placeholder="Enter Employee No" /> </div> </form> </body> </html>
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.