Showing posts with label Validate. Show all posts
Showing posts with label Validate. Show all posts

29 January 2015

How to validate double value in c#.net


 Add namespace: using System.Text.RegularExpressions;



if (Regex.IsMatch(txt_number.Text, @"\d+(\.\d{1,2})?"))
{
    //valid Number
    // Do something with value
}
else
{
    //invalid Number
    lbl_error.Text = "Please enter a valid number";
    return;
}

7 March 2014

Validate Money Currency format in ASP.Net TextBox using Validators

<asp:TextBox ID="txt_Amount" runat="server"></asp:TextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator10" runat="server"
        ControlToValidate="txt_Amount" ErrorMessage="Please enter only numbers like 1000 or 1000.00"
        ValidationExpression="^\d+(\.\d\d)?$"></asp:RegularExpressionValidator>