Jquery
<script type="text/javascript">
var specialKeys = new Array();
specialKeys.push(8); //Backspace
jQuery(document).ready(function () {
$(".numeric").bind("keypress", function (e) {
var keyCode = e.which ? e.which : e.keyCode
var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
$(".intervalError").css("display", ret ? "none" : "inline");
return ret;
});
$(".numeric").bind("paste", function (e) {
return false;
});
$(".numeric").bind("drop", function (e) {
return false;
});
});
</script>
.Aspx Web Form
//Textbox for Entering Age (allowing only numeric values to enter here)<div>
<asp:TextBox CssClass="numeric" ID="txtAge" runat="server" />
</div>
No comments:
Post a Comment