RadMaskedEditBox with EMail MaskType

3 posts, 0 answers
  1. Mustafa
    Mustafa avatar
    2 posts
    Member since:
    Jun 2015

    Posted 15 Jun 2015 Link to this post

    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. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 16 Jun 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mustafa
    Mustafa avatar
    2 posts
    Member since:
    Jun 2015

    Posted 16 Jun 2015 in reply to Hristo Merdjanov Link to this post

    Thank you for your fast response, that was just what i need!
Back to Top