Stop decimal place pence from being entered into a currency entry using a RegularExpressionValidator

Category ASP.Net Sub Category Controls Validation
Bookmark and Share
When entering a currency value this extra use of the RegularExpressionValidator stops the entry of a '.' and thus prevents pence form being entered.
The requirement here was to allow currency to be entered i.e. allowing ',' for separating numbers but not allowing pence.

Copy Code
<asp:TextBox ID="txtTurnover" runat="server" CssClass="textbox" MaxLength="50" Width="80" style="margin-left:15px;"/><strong> Stg</strong> <asp:RequiredFieldValidator ID="rfvTurnover" runat="server" ControlToValidate="txtTurnover" Text="<strong>(*)</strong>" ErrorMessage="(*)" SetFocusOnError="True"> </asp:RequiredFieldValidator><br /> <asp:RegularExpressionValidator ID="regexpName" runat="server" ErrorMessage="No Pence" ControlToValidate="txtTurnover" ValidationExpression="^[\d\,]*$"> </asp:RegularExpressionValidator><br /> <asp:CompareValidator ID="cvTurnover" runat="server" CultureInvariantValues="false" EnableClientScript="true" ValueToCompare="0" Type="Currency" ControlToValidate="txtTurnover" ErrorMessage="Enter Valid Turnover Value" Operator="GreaterThanEqual"> </asp:CompareValidator>
Share the love
Bookmark and Share