Mobile Number textbox1;
Mobile Number should be 10 Digit validation
if (txt_mobile.Text.Length < 10)
{
LblErr.Text = "Enter Correct Mobile Number";
return;
}
Mobile Number start with 0 Validation
if (txt_mobile.Text.StartsWith("0"))
{
LblErr.Text = "Dont start with Mobile Number 0 ";
return;
}
i written the two validation
But i want that two validation to be written in one condition(like one validtion in that both validation should satisfy)
how to do .
please give the code from my above code.
Amit ChoudharyPosted Dec 27, 2012, 4:39 AM
Pawan ChandPosted Dec 27, 2012, 4:17 AM
Amit ChoudharyPosted Dec 27, 2012, 3:42 AM
using System.Text.RegularExpressions;
Here's the code for mobile validation:
public bool IsCorrectMobileNumber(String strNumber)
{
Regex mobilePattern = new Regex(@"^[1-9]\d{10}$"); return !mobilePattern.IsMatch(strNumber);
}
Santhosh Kumar JayaramanPosted Dec 27, 2012, 2:33 AM
//Do next thing
else
//throw error message