Last active
August 29, 2015 13:58
-
-
Save maskaravivek/10370617 to your computer and use it in GitHub Desktop.
Function to validate email address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Style x:Key="TokkriHeaderStyle" TargetType="ContentControl"> | |
<Setter Property="FontSize" Value="16"/> | |
<Setter Property="FontWeight" Value="SemiBold"/> | |
<Setter Property="Foreground" Value="{StaticResource TokkriTheme}"/> | |
<Setter Property="Margin" Value="0,4,0,4"/> | |
<Setter Property="HorizontalAlignment" Value="Left"/> | |
</Style> | |
<Style x:Key="TokkriTextBox" TargetType="telerikPrimitives:RadTextBox"> | |
<Setter Property="HeaderStyle" Value="{StaticResource TokkriHeaderStyle}"/> | |
<Setter Property="Height" Value="108"/> | |
<Setter Property="VerticalAlignment" Value="Center"/> | |
<Setter Property="Background" Value="WhiteSmoke"/> | |
<Setter Property="Foreground" Value="Black"/> | |
</Style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool ValidateEmailID() | |
{ | |
emailfield.ChangeValidationState(ValidationState.Validating, "validating"); | |
bool isValid = isValidEmail(emailfield.Text); | |
if (isValid) | |
{ | |
emailfield.ChangeValidationState(ValidationState.Valid, "great!"); | |
} | |
else | |
{ | |
emailfield.ChangeValidationState(ValidationState.Invalid, "Invalid email address!"); | |
} | |
return isValid; | |
} | |
public static bool isValidEmail(string inputEmail) | |
{ | |
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + | |
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + | |
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; | |
Regex re = new Regex(strRegex); | |
if (re.IsMatch(inputEmail)) | |
return (true); | |
else | |
return (false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<telerikPrimitives:RadTextBox Name="emailfield" Header="EMAIL" Style="{StaticResource TokkriTextBox}"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment