Hi venkatg,
Use Split function.
Refer below code.
C#
string email = "venkat.g.r@gmail.com";
if (email.Split('@').Length > 1)
{
if (email.Split('@')[0].Split('.').Length > 1)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('valid')", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Invalid')", true);
}
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Invalid')", true);
}
VB.Net
Dim email As String = "venkat.g.r@gmail.com"
If email.Split("@"c).Length > 1 Then
If email.Split("@"c)(0).Split("."c).Length > 1 Then
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('valid')", True)
Else
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Invalid')", True)
End If
Else
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Invalid')", True)
End If