Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/10/2010, 13:13
Goomba
 
Fecha de Ingreso: abril-2003
Ubicación: Santiago
Mensajes: 212
Antigüedad: 21 años, 1 mes
Puntos: 0
Jquery Validate y Tipsy

Hola como estan todos bueno les comento lo siguiente sucede que estoy haciendo un formulario y estoy utilizando para la validacion el plugin de jquery validate, lo que quiero hacer es cuando haya algun error se despliegue un tooltip sobre el campo que tiene error indicando algun mensaje ademas de agregar una imagen al lado de cada campo que indique si esta correcto o no.
la idea es que si el campo se valide el tooltip se esconda y es ahy dodne tengo mi error.
Código Javascript:
Ver original
  1. <script type="text/javascript" >
  2. $.validator.setDefaults({
  3.      
  4.      debug: true,
  5.                 errorElement: "em",
  6.                 //errorContainer: $("#warning, #summary"),
  7.                 errorPlacement: function(error, element) {
  8.                     error.appendTo( element.parent("td").next("td") );
  9.                 },
  10.                 success: function(label) {
  11.                     hideValidTooltip()
  12.                     label.text("ok!").addClass("success");
  13.                    
  14.                 },
  15.                 rules: {
  16.                     firstname: {
  17.                         required: true,
  18.                         minlength: 2,
  19.                         maxlength: 4  
  20.                     },
  21.                     rut: {
  22.                         required: true,
  23.                         minlength: 8,
  24.                         maxlength: 10,
  25.                         validateRUT:true
  26.                     }
  27.                 },
  28.                 messages: {
  29.                     firstname: {
  30.                         required: "Mensaje Error Requerido",
  31.                         minlength: "Mensaje Error Min Lenght",
  32.                         maxlength: "Mensaje Error Max Lenght"      
  33.                     },
  34.                     rut: {
  35.                         required: "Mensaje Error Requerido",
  36.                         minlength: "Mensaje Error Min Lenght",
  37.                         maxlength: "Mensaje Error Max Lenght",
  38.                         validateRUT:"Rut Malo"
  39.                     }                                                                                                                    
  40.                 }
  41.     });
  42.  
  43. </script>
  44. <script type="text/javascript">
  45.         $(function(){
  46.             $('input').tipsy({trigger: 'manual', gravity:'w'});
  47.            $('#Button1').click(function() {
  48.               $('input').each(function(index) {
  49.                 if($(this).valid()== false) {
  50.                     $(this).attr("title", "hola"+index );
  51.                     $(this).tipsy("show");
  52.                 }
  53.               });
  54.             });
  55.             $('#Button2').click(function() {
  56.               $('input').each(function(index) {
  57.                 if($(this).valid()== false) {
  58.                     $(this).attr("title", "hola"+index );
  59.                     $(this).tipsy("hide");
  60.                 }
  61.               });
  62.             });
  63.            $('#<%=this.Master.formName%>').validate({
  64.                
  65.            });
  66.          });
  67.         function hideValidTooltip() {
  68.               $('input.valid').each(function(index) {
  69.                     $(this).attr("title", "hola"+index );
  70.                     $(this).tipsy("hide");
  71.               });
  72.         }
  73.     </script>
  74. <table border="1" cellpadding="0" cellspacing="0" style="width: 100%;">
  75.     <tr>
  76.         <td>
  77.             <label for="firstname">Name</label>
  78.         </td>
  79.         <td>
  80.             <input id="firstname" name="firstname" title="Ingrese su Nombre" />
  81.         </td>
  82.         <td></td>
  83.      </tr>
  84.     <tr>
  85.         <td>
  86.             <label for="rut">Name</label>
  87.         </td>
  88.         <td>
  89.             <input id="rut" name="rut" title="Ingrese su Rut" />
  90.         </td>
  91.         <td></td>
  92.     </tr>
  93.     <tr>
  94.         <td>
  95.              &nbsp;
  96.         </td>
  97.         <td>
  98.             &nbsp;
  99.         </td>
  100.         <td>
  101.             &nbsp;
  102.         </td>
  103.     </tr>
  104. </table>
  105.     <input class="submit" type="submit" value="Submit"/>
  106.     <input id="Button1" type="button" value="button" />
  107.      <input id="Button2" type="button" value="button" />



por ejemplo el primer input text ingreso un texto de 2 caracteres como minimo y maximo de 4.
si ingreso un valor correcto me muestra el mensaje del lado i la imagen lo mismo si esta equivocado, mi problema esta que cuando este esta erroneo el toltip se muestra pero cuando ingreso un dato corrcto este no se esconde al momento de ingresar 2 textos

Acontinuacion adjunto una imagen con los 3 paso por ejemplo, ademas seria ideal poder hacer que si el campo vuelve a pasar a estar incorrecto se vuelva a mostrar el tooltip ojala alguien pueda ayudarme