Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

c# - How do I get shaded textbox when form validation fails?

This code is from a form in my ASP.NET MVC application.

Using the code below, when the form field FirstName is blank, the error message is displayed in Red. What do I need to do, to get the text box to have the red border and shaded background that is common on sites?

Thanks for any help on this.

Model class field:

 [Required (ErrorMessage ="You must enter a first name")]
 public string FirstName { get; set; }

Form field:

 <div class="form-row">
     <label for="FirstName" class="col-3 col-form-label">Number of users to process:</label>
     @Html.TextBoxFor(m => m.FirstName, new { @class = "col-6 form-control" })
     @Html.ValidationMessageFor(m => m.FirstName, null, new { @class = "text-danger" })
 </div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...