ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Required field indicated on inputs?
Title:
B
I
{code}
?
How are required fields denoted to user on an empty form ? Typically there's a `*` next to the label or input, but looking around the demos I don't see examples
Save Changes
Cancel
Stephan Luis
asked at 18 Sep 2018
Answers
B
I
{code}
?
using our demos code ( main, minsetup, both mvc 5 and ASP.net core) in `_FieldLayout.cshtml` you can add the `*` after `RenderBody()`, this will add it after the input ... <div class="einput"> @RenderBody() @(ViewData.ModelMetadata.IsRequired ? "*" : "") </div> if you need it after the label, add it after the call to `@Html.Label` <div class="elabel"> @Html.Label("", ... @(ViewData.ModelMetadata.IsRequired ? "*" : "") </div> so now when you call `@Html.EditorFor` you'll get the `*` for required properties in your viewmodel
Save Changes
Cancel
Omu
answered at 19 Sep 2018
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK