Showing posts with label Double value. Show all posts
Showing posts with label Double value. 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;
}