0

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?

Brad Rem
  • 6,036
  • 2
  • 25
  • 50
user1164706
  • 11
  • 1
  • 3

2 Answers2

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

Community
  • 1
  • 1
Miika L.
  • 3,333
  • 1
  • 24
  • 35
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