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

Email Address

1 Answer 436 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Eric Moore
Top achievements
Rank 1
Eric Moore asked on 17 May 2011, 02:50 PM
Is there a way to use the masked input to force proper email address formatting?
something along the lines of Mask="a25\@a25.LLL" or even better Mask="A3a25\@A3a25.L3"
I'd like it so that when the user types an '@' it skips the rest of the email prefix characters.
Same thing when they type the '.'
Can anyone think of a simple way to do this where I don't have to check the characters pressed in the code behind. That just seems like it wouldn't be a very cost efficient trasaction.

Eric

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Fidanov
Telerik team
answered on 19 May 2011, 09:34 AM
Hi Eric Moore,

The control does not support this, however, what you can do is to validate the input against a regular expression. For example:

public class Context : ViewModelBase
{
    private string emailAddress;
    [RegularExpression(@"\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b")]
    public string EmailAddress
    {
        get { return emailAddress; }
        set 
        
            emailAddress = value; 
            this.OnPropertyChanged("EmailAddress"); 
        }
    }
}

<telerik:RadMaskedTextInput Mask="a30" Value="{Binding EmailAddress, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"/>


In case of invalid input, a red border will be craeted around the control prompting for the error. Moreover, you can customize this by craeting and applying an Error template through the Validation.ErrorTemplate attached property.

Greetings,
Alex Fidanov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Eric Moore
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or