Using RegularExpressionValidator for numbers only in textbox

asp.net, c#, visual-studio-2012, webforms

Solution

This checks first if textbox is blank and then it checks for numbers only.

<asp:TextBox ID="tbAccount" runat="server"></asp:TextBox>

Checks if textbox is blank:

<asp:RequiredFieldValidator ID="RequiredFieldValidatorAccount" runat="server" ErrorMessage="*Required" ControlToValidate="tbAccount" ForeColor="Red"></asp:RequiredFieldValidator>

Allows only numbers:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="tbAccount" ErrorMessage="Please Enter Only Numbers" ForeColor="Red" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>

Problem

Visual Studio 2012, Asp.net, webforms. Trying to control input into textbox, numbers only. I have the following code: ``` <asp:RegularExpressionValidator id="RegularExpressionValidator1" ControlToValidate="txtAcres" ValidationExpression="^\d+" Display="Static" ErrorMessage="Only Numbers" EnableClientScript="False" runat="server"></asp:RegularExpressionValidator> ``` but i am allowed to enter any text. What am I missing?

Original source