How to hide the message in bootstrap?

Asked

Viewed 290 times

2

Look at the picture

inserir a descrição da imagem aqui

When I open the modal form it already appears the validation message track, I would like it to appear only when the validation is activated.

It’s that piece of code;

   <div class="alert alert-danger" role="alert">
                          <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="false"></span>
                          <span id="erroMsgUJ"></span>
                          <span id="erroMsgPeriodoInicio"></span>
                    </div>
  • Enter the javascript code that validates and displays Alert.

1 answer

3


Just start him off with display:none, for this you can use the native class .hidden Bootstrap 3 as you can see here: https://getbootstrap.com/docs/3.3/css/#helper-classes-show-Hide

// Classes
.show {
  display: block !important;
}
.hidden {
  display: none !important;
}

So your div of Alert would initially look like this, then you remove the .hidden and puts the .show by JS already using these native BS3 classes

<div class="alert alert-danger hidden" role="alert">
  • didn’t work, but I saw the documentation, I think it must be missing something!

  • Please, based on my code as it would look?

  • @wladyband just that should solve <div class="alert alert-danger hidden" role="alert"> but if not solved, it is because you have some Script that this putting display:block in this element... maybe some jQuery who is giving show() in the element... just inspecting to know why the tag might be like this <div class="alert alert-danger hidden" role="alert" style="display:block"> there is no way to work, you would have to take this block by JS too

Browser other questions tagged

You are not signed in. Login or sign up in order to post.