November Happy Hour will be moved to Thursday December 5th.

Using attributes

Vote:
 

Hi all,

I have a problem with the use of attributes (both standard and with custom).

PROBLEM:
I want to use to validate the input text email address (you can do this:

1) [DataType (DataType.EmailAddress)];

2) [RegularExpression (@ "^ ([A-Za-z0-9._% + -] + @ [A-Za-z0-9. -] + \. [A-Za-z] {2,9}) $ ", ErrorMessage =" Must be valid email address ")];

3) create custom attribute [EmailAddress])

If I use another attribute to the field [Requered] then before creating a page (block) episerver offers to fill in all the fields that are marked as [Requered]. And at this point, he ignores all attributes except described in second solution [RegularExpression()].

How to make in this window are used all the attributes?

Hope for your help

 

#73949
Aug 15, 2013 7:47
Vote:
 

you can just use EmailAddress attribute instead. In my side, I use both Required and EmailAddress attribute on one property, it works just good. such as the following :

        [Required(ErrorMessage = "Email is required")]
        [EmailAddress(ErrorMessage = "Email is not valid")]
        public virtual string Email { get; set; }

#74442
Aug 28, 2013 4:12
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.