0

I have add some special characters to be accepted by the input text field In model

[RegularExpression(@"^[a-zA-Z./@/- ]+$", ErrorMessage = "The Last Name field should contain letters only.")]
public string LastName { get; set; }

This makes to throw error like parsing "^[a-zA-Z./@/- ]+$" - [x-y] range in reverse order
But requirement is to accept these " / , - @ " special character also by the field.

anand
  • 1,505
  • 4
  • 20
  • 40
  • 1
    Well, so, try `@"^[a-zA-Z. /,@-]+$"` and adjust the error message accordingly. What issue have you got with that task? – Wiktor Stribiżew Mar 31 '16 at 11:41
  • @anand What's the question? As mentioned above it's a fairly easy thing to do, so what is the problem? – Biffen Mar 31 '16 at 11:42
  • to make the input to accept those addition special characters by updating the regular expression in data annotations – anand Mar 31 '16 at 11:44
  • 1
    @anand: That is the *task*, what is the *issue/problem* you have? – Wiktor Stribiżew Mar 31 '16 at 11:44
  • @anand As for the error: Put the hyphen at the end of the class, otherwise you're creating a (invalid) range from slash to space. (And remove the extra slash while you're at it.) – Biffen Mar 31 '16 at 11:49
  • 1
    See [*.NET Regex Error: \[x-y\] range in reverse order*](http://stackoverflow.com/questions/7476922/net-regex-error-x-y-range-in-reverse-order). Someone please re-close. – Wiktor Stribiżew Mar 31 '16 at 11:50

0 Answers0