asp.net - Special Characters with Data Annotation MVC4 -
i have done validations using mvc4 data annotations.
and restricted special characters too.
but want allow spaces between each words.
i tried this:
[required(errormessage = "category name should not empty")] [regularexpression(@"^[a-za-z0-9]+$", errormessage = "special character should not entered")] public virtual string name { get; set; }
right system not allowing me insert. because have entered space. considering space special char.
how allow space? same time above validation should work.
myself found answer.
instead of @"^[a-za-z0-9]+$"
need add @"^[a-za-z0-9'' ']+$"
.
''single space'
in expression
'' '
for more information i'd suggesting reading - using data annotations customize data classes (msdn)
Comments
Post a Comment