Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
@Html.TextBoxFor(Model => Model.Topic, new { @class = "form-control Topic ", data-Validator="email",  placeholder = "Enter Topic",  required = "required" })

data-validate="email" is working fine with html controls but not working with html helper.
Posted
v2

1 solution

Property names in C# cannot contain the "-" character. The workaround is to use the "_" character instead, which the MVC helper should then convert to a "-" in the rendered markup:
@Html.TextBoxFor(Model => Model.Topic, new { @class = "form-control Topic", data_validate = "email", placeholder = "Enter Topic",  required = "required" })
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900