dimanche 28 juin 2015

ASP.NET MVC regular expression for comma separated strings

I need to do MVC unobtrusive client side validation using regular expression in my ASP.NET MVC 5 project.

Valid Input is comma separated string values, for example: string1, string2, string 3 etc.

I tried below regEx pattern for comma separated strings but it's not working as expected. Could anyone tell me what's wrong in below expression ?

[RegularExpression(@"/^[a-zA-Z]{1,20},[a-zA-Z]{1,20}$/",
                        ErrorMessage = "Please enter comma separated list")]
    public string SettingOptions { get; set; }

Thanks in Advance.

Aucun commentaire:

Enregistrer un commentaire