regex - DataAnnotation TextArea Multiple Emails -
i using mvc 3.
i have text area in user can enter multiple emails addresses. emails can separated comma , space. user may hit enter in box well.
is there attribute can handle scenario?
i using regular expression check characters , failing "abc@abc.com, tyz@tyz.com"
here regular expression: [regularexpression(@"([a-za-z0-9 .@-_\n\t\r]+)", errormessage = validationmessageconstants.emailadressinvalid)]
what missing here? regular expression off following post: dataannotations validation (regular expression) in asp.net mvc 4 - razor view
you not stating question is, have assume answer data annotations aren't working expect.
having assumption in mind, easy why not working: data annotation operates on entire field, text area in case. work expected if have 1 email. since have multiple emails in field, separated comma or space, field in entirety doesn't reflect data annotation email prescribes , fails.
to answer numbered questions:
no, there no out of box
the regular expression using doesn't account multiple emails, one. solution in case either
- data annotation using regex multiple emails separated you'd or
- have custom validation attribute doing
following links above see examples of "how to" , going in right direction. hope helps, please let me know if not.
Comments
Post a Comment