Allowing Numeric Inputs For Textbox

2011-06-18

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<head runat="server">
 
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
 
 
<script language="javascript" type="text/javascript">
 
jQuery.fn.ForceNumericOnly =
function () {
return this.each(function () {
$(this).keydown(function (e) {
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
return (
key == 8 ||
key == 9 ||
key == 46 ||
(key >= 37 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
})
})
};
 
$(document).ready(function () {
$("#txtTransactionID").ForceNumericOnly();
});
 
 
</script>
</head>


0 comments: