Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

problem to validate email address

$
0
0

Hi All.

I'm trying to validate email address in the text field

<xctk:WatermarkTextBox x:Name="EmailTextBox" Watermark="Email Address" VerticalContentAlignment="Center" 
Grid.Column="1" Grid.Row="3" TabIndex="3" Height="30" TextChanged="EmailTextBox_TextChanged"
LostFocus="EmailTextBox_LostFocus" ><Binding Path="EmailAddress" /></xctk:WatermarkTextBox><TextBlock x:Name="errEmail" Text="" FontSize="10" Foreground="#FFFF0000" Margin="5" Grid.Column="1" Grid.Row="3"
VerticalAlignment="Top" TextAlignment="Right" />

On online I found that code

bool IsValidEmail(string email)
{
    try {
        var addr = new System.Net.Mail.MailAddress(email);
        return addr.Address == email;
    }
    catch {
        return false;
    }
}

How to apply this code for LostFocus event method?

Thanks.





Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>