<asp:Label ID="lbltxtcitycode" runat="server" CssClass="col-md-4 control-label font-isstyle-large fontisstylealign" Text="<%$ Resources:EN_Resource, BIS00013 %>">
<asp:TextBox ID="txtCityAbbr" runat="server" CssClass="form-control">
<asp:RequiredFieldValidator ID="rfvCityAbbr" runat="server" Display="None" ControlToValidate="txtCityAbbr"
ErrorMessage="City abbreviation missing." ToolTip="Enter city abbreviation.">
<asp:ValidatorCalloutExtender ID="vceCityAbbr" CssClass="errorstyle" runat="server" TargetControlID="rfvCityAbbr" PopupPosition="BottomLeft"
Enabled="true" CloseImageUrl="~/_ImgIcons/clo.png" WarningIconImageUrl="~/_ImgIcons/war.png">
For allowing only numbers wrote script as :
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
$(document).ready(function () {
$("#txtCityAbbr").keydown(function (e) {
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
(e.keyCode >= 35 && e.keyCode <= 40)) {
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
});
<asp:UpdatePanel runat="server">
<contenttemplate>
.
.
.
What I have tried:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
$(document).ready(function () {
$("#txtCityAbbr").keydown(function (e) {
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
(e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
(e.keyCode >= 35 && e.keyCode <= 40)) {
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
});
<asp:UpdatePanel runat="server">
<contenttemplate>