How to validate textbox containing website, email information
I want to check textbox field where a user will be giving website address or email address.
www.xyz.com -- I want to check whether actual web address format is given or not.
[email protected] -- I want to check whether actual email address format is given or not.
Can anybody help me?
Bechir BejaouiPosted Oct 27, 2008, 7:25 AM
dont forget to include System.Text.RegualrExpressions namespace
public textBox_Validating(object sender, eventarg e)
{
if(Check(textbox.text))
{
instruction1;
}
else
{
instruction 2;
}
}
public bool Check(string input)
{
bool response = false;
if(Regex.IsMatch(input,@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
{response = true;}
else { response = false; }
return response;
}