<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JQuery
Keydown Event in ASP.NET</title>
<script type="text/javascript" language="Javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#txtbox").keydown(
function (e) {
if (event.keyCode == 13) {
$("#lblShow").text("You have pressed Enter Key");
}
else if
(event.keyCode == 32) {
$("#lblShow").text("You have
Pressed Spacebar Key");
}
else
if (event.keyCode == 18) {
$("#lblShow").text("You have
Pressed Alt Key");
}
else if
(event.keyCode >= 48 && event.keyCode <= 57) {
$("#lblShow").text("You have Entered Numeric values");
}
else if
(event.keyCode == 27) {
$("#lblShow").text("You have Pressed Escape Key");
}
else if
((event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode
>= 97 && event.keyCode <= 122)) {
$("#lblShow").text("You have
Entered Alphabet Key");
}
else {
$("#lblShow").text("You have
Presses Alphabet Key" + e.keyCode);
}
}
);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<h4>JQuery
Keydown Event in ASP.NET</h4>
<hr />
<b>Enter in
Textbox</b><br />
<asp:TextBox ID="txtbox" runat="server" />
<asp:Label ID="lblShow" runat="server" ForeColor="Red"></asp:Label>
<br />
<br />
</form>
</body>
</html>
|
No comments:
Post a Comment