admin管理员组

文章数量:1418112

I'm using twitter bootstrap and alert elements to use within my web page and I want to use this as validation summary towards the top section of my page.

The issue that I have is when I use "alert alert-danger" on my create.chstml page, this displayed the red warning bar by default when the page is loaded.

The actual validation works on the form fields they are supposed to, however, I just need to find a way of hiding this warning bar when the page loads and then get this to kick in when my create button has been clicked.

I have tried some of the bootstrap properties like Hidden:hidden but this doesn't seem to work. Can I use javascript to plete this task and link this to the button create I have?

Here is the bootstrap I have on my create.cshtml

        <div class="form-horizontal">
            <div class="row" >
                <div class="alert">
                    @Html.ValidationSummary(false, " ", new { @class = "text-danger alert alert-danger" })
                </div>
            </div>
       </div>

I'm using twitter bootstrap and alert elements to use within my web page and I want to use this as validation summary towards the top section of my page.

The issue that I have is when I use "alert alert-danger" on my create.chstml page, this displayed the red warning bar by default when the page is loaded.

The actual validation works on the form fields they are supposed to, however, I just need to find a way of hiding this warning bar when the page loads and then get this to kick in when my create button has been clicked.

I have tried some of the bootstrap properties like Hidden:hidden but this doesn't seem to work. Can I use javascript to plete this task and link this to the button create I have?

Here is the bootstrap I have on my create.cshtml

        <div class="form-horizontal">
            <div class="row" >
                <div class="alert">
                    @Html.ValidationSummary(false, " ", new { @class = "text-danger alert alert-danger" })
                </div>
            </div>
       </div>
Share Improve this question edited Dec 19, 2016 at 11:43 Hudhaifa Yoosuf 9192 gold badges13 silver badges28 bronze badges asked Dec 19, 2016 at 11:31 Betty LazzariBetty Lazzari 991 gold badge6 silver badges13 bronze badges 1
  • 1 dddddduplicate check out the answer here – George Commented Dec 19, 2016 at 11:34
Add a ment  | 

1 Answer 1

Reset to default 2

Just use the hide class of bootstrap and when you click on button you can remove that class.

<div class="form-horizontal">
   <div class="row" >
      <div class="alert hide"> //add class here
          @Html.ValidationSummary(false, " ", new { @class = "text-danger alert alert-danger" })
      </div>
   </div>
</div>

It will hide the alert on the page load and will work on button click as you want.

本文标签: javascriptbootstrap alertdanger hide when page loadsStack Overflow