This is a migrated thread and some comments may be shown as answers.

RadMaskedEditBox with EMail MaskType

2 Answers 259 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Mustafa
Top achievements
Rank 1
Mustafa asked on 15 Jun 2015, 11:58 PM

Hi, 

I am using RadMaskedEditBox with EMail MaskType on my project. I want to know if its text is a valid email or not on the code side but i couldn't find a way to do it. How can i get the bool value of valid email address of RadMaskedEditBox?

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 16 Jun 2015, 10:44 AM
Hi Mustafa,

Thank you for writing.

You could subscribe your RadMaskedEditBox to the Validating event and in the handler perform a check if the text in the input is valid. Based on the result you can cancel the event and continue with your logic. Please see my code snippet below: 
public Form1()
{
    InitializeComponent();
 
    this.radMaskedEditBox1.MaskType = Telerik.WinControls.UI.MaskType.EMail;
    this.radMaskedEditBox1.Validating += radMaskedEditBox1_Validating;
}
 
private void radMaskedEditBox1_Validating(object sender, CancelEventArgs e)
{
    bool isValid = ((EMailMaskTextBoxProvider)this.radMaskedEditBox1.MaskedEditBoxElement.Provider).Validate(this.radMaskedEditBox1.Text);
    if (!isValid)
    {
        // TODO:...
    }
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mustafa
Top achievements
Rank 1
answered on 16 Jun 2015, 12:18 PM
Thank you for your fast response, that was just what i need!
Tags
MaskedEditBox
Asked by
Mustafa
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Mustafa
Top achievements
Rank 1
Share this question
or