Guides (SDK /API)Technical ReferenceBBDNHow-to Documentation

You are here: Custom Parts Example: Pledge Form > Add Field Validation for Amount

Add Field Validation for Amount

Code sample project: Custom Pledge Form

Note: For some common regular expressions for field validation, see Microsoft's MSDN article at: How To: Use Regular Expressions to Constrain Input in ASP.NET. There are also some default regular expressions in the editor for the ValidationExpression field on the Properties window for the RegularExpressionValidator control.

Add a regular expression validator to ensure that TextBoxAmount has a valid currency amount.

    <br />
    <asp:Label ID="Amount" runat="server" Text="Amount"></asp:Label>
    <asp:RequiredFieldValidator ID="RequiredFieldValidatorAmount" ControlToValidate="TextBoxAmount" runat="server" ErrorMessage="Amount required">*</asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="RegularExpressionValidatorAmount" ControlToValidate="TextBoxAmount" ValidationExpression="^\d+(\.\d\d)?$" runat="server" ErrorMessage="Invalid amount"></asp:RegularExpressionValidator>
    <br />