2012-03-31 99 views
1

我使用的標題jQuery驗證插件和存儲的錯誤信息,如:不顯示輸入元素上懸停時的標題文本

<input type="text" name="email" class="required email" title="Bad email format" /> 

我不希望標題文本「壞電子郵件格式」來在懸停時顯示。如何禁用此功能(如果可能的話)?

回答

1

嘗試使用rel="Bad email format" insted的標題或HTML數據屬性,如data-errorMssg="Bad email format"如果你不能在這裏使用它們是一個提取的代碼隱藏標題

(function($){ 
$.fn.hide_my_tooltips = function() { 


    return this.each(function() { 

     $(this).hover(function(e) { 
      // mouseover 
      var $this=$(this); 
      $this.data("myTitle",$this.attr("title")); //store title 
      $this.attr("title",""); 
      }, function() { 
      // mouseout 
      var $this=$(this); 

      $this.attr("title",$this.data("myTitle")); //add back title 
     }); 

     $(this).click(function() { 
      var $this=$(this); 
      $this.attr("title",$this.data("myTitle")); //add back title 
     }); 
    }); 
}; 
})(jQuery); 

//在文件準備函數調用正確的選擇的JQ功能。 $(「input」)。hide_my_tooltips();

+0

謝謝,這個函數正在工作,「rel」和「data-Msg」不起作用 – 2012-03-31 13:18:12

0

您需要在其他地方存儲錯誤消息。例如,在JavaScript數組中:

var errors = { "emailformat" : "Bad email format" } 

並隨時隨地處理它,從數組中調用它而不是從html中調用它。

+0

你能指定我可以如何使用jQuery驗證插件嗎?我是否必須爲每個輸入元素添加特殊規則? – 2012-03-31 13:08:54

相關問題