数据注释MVC3注释、数据

由网友(无法复原的爱)分享简介:是否有可能使用的DataAnnotations来限制用户从输入特殊字符?Is it possible to use DataAnnotations to restrict user from enter special character?我希望用户只输入包括AZ,az和0-9成一个文本框。 I want the...

是否有可能使用的DataAnnotations来限制用户从输入特殊字符?

Is it possible to use DataAnnotations to restrict user from enter special character?

我希望用户只输入包括AZ,az和0-9成一个文本框。

I want the user to enter only A-Z, a-z and 0-9 into a textbox.

我需要做这个客户端上。

I need to do this on the client side.

推荐答案

是的,你可以使用普通的防爆pression为...

yes you can use Regular Expression for that...

[Required(ErrorMessage = "Enter Foo !")]
[RegularExpression(@"^[a-zA-Z0-9]+$", ErrorMessage = "Incorrect Entry dude !")]
public string Foo { get; set; }
阅读全文

相关推荐

最新文章