hi
I have post the code for How to fire JavaScript and JQuery in Textbox Keypress event.
Client Side Code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language ="javascript" src="Scripts/jquery-1.4.1.js"></script>
<script language ="javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" language="javascript">
function validateNumbersOnly(e) {
var unicode = e.charCode ? e.charCode : e.keyCode;
if ((unicode == 8) || (unicode == 9) || (unicode > 47 && unicode < 58)) {
return true;
}
else {
window.alert("This field accepts only Numbers");
return false;
}
}
$(document).ready(function () {
$("#TextBox2").keypress(function () {
alert('Check this');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
Asp TextBox : <asp:TextBox ID="numericTextBox" runat="server" onkeypress="return validateNumbersOnly(event);"></asp:TextBox> <br />
Html Control: <input id="txtName" runat="server" maxlength="32" onkeypress="return validateNumbersOnly(event);"> <br />
JQuery TextBox : <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</form>
</body>
</html>
Hello JayaKumar,
It is Working in Javascript but it is not working in jquery.I added .Js file also.Please check it edit ur post.
Posted by:
Jayakumars
on: 10/17/2012
Level:Bronze | Status: [Member] [MVP] | Points: 10
Hello
hari
are u working in this code? which browser? working good for me
see this image
Hello JayaKumar,
i'm using ie8 and google chrome,firefox.Jquery code is working for alert message only.it is accepting characters also .But javascript code is working very well.
Thanq