RadMaskedEditBox using Email MaskType. How to prevent user from leaving field when it fails validation

1 Answer 13 Views
MaskedEditBox
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
Gone2TheDogs asked on 03 Feb 2025, 08:21 PM

Regarding the RadMaskedEditBox using the provided Email MaskType:

The error validation icon displays when there is an error, but it doesn't prevent the user from leaving the field. 

How can I prevent the user from leaving the field with this MaskType?

 

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 05 Feb 2025, 02:41 PM

Hello Bob Neuendorf

Thank you for reaching out to us.

What I can suggest to try is to cancel the Validating event of the control. The Provider of the RadMaskedEditBox.MaskedEditBoxElement exposes the Validate() method which you can use in code:

this.radMaskedEditBox1.Validating += RadMaskedEditBox1_Validating;

private void RadMaskedEditBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
    bool isValid = ((EMailMaskTextBoxProvider)this.radMaskedEditBox1.MaskedEditBoxElement.Provider).Validate(this.radMaskedEditBox1.MaskedEditBoxElement.Text);
    if (!isValid)
    {
        e.Cancel = true;
    }
}

I hope that this approach will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
commented on 05 Feb 2025, 06:15 PM

Perfect. Thanks!
Tags
MaskedEditBox
Asked by
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or