How to disable Shift key in text box control using jquery


In this article I'm going to explain How to disable Shift key in text box control using jquery. Just drag and drop one text box control to your asp.net web page. When user try to press Shift key control its not allowing.

In this article I'm going to explain How to disable Shift key in text box control using jquery.

Just drag and drop one text box control to your asp.net web page. When user try to press Shift key control its not allowing.

Example:



<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#txtShiftKey").keydown(function(event) {
if (event.shiftKey) {
alert('You have pressed Shift Key.');
event.preventDefault();
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtShiftKey" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>


Comments



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: