Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/11/2013, 11:21
charlyta
 
Fecha de Ingreso: junio-2008
Mensajes: 291
Antigüedad: 15 años, 10 meses
Puntos: 9
Respuesta: error al presionar boton por segunda vez

Hola y gracias por la atención al tema. Esta ha sido mi solución:

div de alerta:

Código HTML:
Ver original
  1. <div id="alerta" class="alert alert-error"  style="display: none">
  2.                         <!--<button type="button" class="close" data-dismiss="alert">×</button>-->
  3.                          <a class="close" onclick="$('#alerta').hide()">×</a>  
  4.                         <h4>Se ha producido el siguiente error:</h4>
  5.                         No ha indicado ningún término de búsqueda.
  6.                     </div>



javascript:


Código Javascript:
Ver original
  1. <script>
  2. function validate(){
  3. var fields = new Array;
  4. var fields = [document.getElementById('autor'),document.getElementById('titulo')];
  5. var err = 0;
  6.  
  7.  
  8. for (i=0;i<fields.length;i++){
  9.  
  10. if (fields[i].value == ""){
  11. err++;
  12. }
  13. }
  14.  
  15. if (err === 0){
  16.  
  17. document.myform.submit();
  18.  
  19. }else {
  20.  
  21. $('#alerta').show()
  22.  
  23.  
  24. return false;
  25. }
  26. }
  27. </script>
  28. <script>
  29. $(function(){
  30.     $("[data-hide]").on("click", function(){
  31.         $("." + $(this).attr("data-hide")).hide();
  32.  
  33.     });
  34. });
  35. </script>


acción:

Código HTML:
Ver original
  1. <input type="button" value="Buscar" onClick="validate();" onClick="validate();"/>