<asp:TextBox ID="txtdigit" runat="server" MaxLength="4"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txtdigit" ValidationExpression="^[0-9]+$" runat="server" ErrorMessage="Please enter only numeric value."></asp:RegularExpressionValidator>