Apply Twitter Bootstrap Validation Style and Message to ASP.NET MVC validation

前端 未结 12 1627
星月不相逢
星月不相逢 2021-01-30 00:57

How can I integrate ASP.NET MVC unobtrusive validation and Twitter Bootstrap? I want to have all those validation messages and styles appropria

12条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 01:46

    You can add a few classes to your Site.css file:

    /* styles for validation helpers */
    .field-validation-error {
        color: #b94a48;
    }
    
    .field-validation-valid {
        display: none;
    }
    
    input.input-validation-error {
        border: 1px solid #b94a48;
    }
    
    select.input-validation-error {
        border: 1px solid #b94a48;
    }
    
    input[type="checkbox"].input-validation-error {
        border: 0 none;
    }
    
    .validation-summary-errors {
        color: #b94a48;
    }
    
    .validation-summary-valid {
        display: none;
    }
    

    FYI: http://weblogs.asp.net/jdanforth/form-validation-formatting-in-asp-net-mvc-5-and-bootstrap-3

提交回复
热议问题