I have a TextBox/RichTextBox in XAML that I want to validate to make sure it contains a string with an '@' symbol. I am using this feature to accept an appropriate email address. How can I do it?
Asked
Active
Viewed 1,698 times
2 Answers
0
One option would be to create a ValidationRule as detailed in the accepted answer here. As for the actual RegEx to use, it depends on how detailed you want the check to be.
(Very) Simple: ^[\w.]+@[\w-]+.[a-z]+$
Complex options: Many options available
0
You can Get the textbox text string from C# and see if it contains the stuff you need for email
example
XAML & C#
<TextBox Name="txt1" Text="abc@def.com"/>
C#*****************************
bool valid = txt1.Text.contains("@")
if(valid)
{
whololo
}

TGB
- 1