Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Client Side Validation Message Error

Can somebody tell me why "This field is required" and "Please insert database name" are being displayed instead of just "Please insert database name"?

Screenshot

This is my model :

public class InstallViewModel
    {
        [Required(AllowEmptyStrings = false, ErrorMessage = "Please insert database name")]
        public string DatabaseName { get; set; }

and this is my view :

<div class="input-group">
    <span class="input-group-addon">Database</span>
    @Html.TextBoxFor(w => w.DatabaseName, new { @class = "form-control", placeholder = "Database name" })
</div>
@Html.ValidationMessageFor(w=> w.DatabaseName)

Thank you.

EDIT:

Can you see the image attached ? I have some problems uploading images.

The view is a partial view and this is the whole partial view:

@Html.ValidationMessageFor(w => w.DatabaseName)
    <div class="input-group">
        <span class="input-group-addon">Database</span>
        @Html.TextBoxFor(w => w.DatabaseName, new { @class = "form-control", placeholder = "Database name" })
    </div> 
    <br />
    @Html.CheckBoxFor(w => w.UseWindowsAuthentication, new { @checked = "checked" }) Use Windows Authentication<br /><br />
    <div class="wizard-sqlauth" style="display: none">
        <div class="input-group">
            <span class="input-group-addon">User name</span>
            @Html.TextBoxFor(w => w.UserName, new { @class = "form-control", placeholder = "User name" })
        </div>
        @Html.ValidationMessageFor(w => w.UserName)<br />
        <div class="input-group">
            <span class="input-group-addon">Password</span>
            @Html.PasswordFor(w => w.Password, new { @class = "form-control" })
        </div>
        @Html.ValidationMessageFor(w => w.Password)
    </div>
like image 254
Branislav B. Avatar asked Nov 27 '25 02:11

Branislav B.


1 Answers

DatabaseName is "Required" and your input is empty. (There is only placeholder text)

like image 55
Krahu Avatar answered Nov 28 '25 15:11

Krahu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!