MustafaP
MustafaP

Reputation: 6633

MVC Model regex allow five whitespace character

 [RegularExpression("^\\d{5}$||d{0}", ErrorMessage = "Girdiğiniz değer 5 karakter uzunluğunda olmalıdır ve rakamlardan oluşmalıdır")]
 public string PostaKodu { get; set; }

When I get PostaKodu from old database , it returns value as five space character if it is null. In form view, it gives validation error. How can i add five white space character to my regular expression

Upvotes: 0

Views: 1274

Answers (1)

Rolice
Rolice

Reputation: 3103

You should modify your expression like use spaces like \s, this is the character for white space in regular expression. Something like \\d{5}$||d{0}||^\\s{5}$ would do the job :D

Upvotes: 1

Related Questions