Reputation: 3530
I'm using jQuery Validate plugin and store Error messages in title, e.g.:
<input type="text" name="email" class="required email" title="Bad email format" />
I don't want the title text "Bad email format" to be shown upon hover. How can I disable this function (if it's possible)?
Upvotes: 1
Views: 2218
Reputation: 2774
Try to use rel="Bad email format"
insted title or html data attributes like data-errorMssg="Bad email format"
if you cant use them here is an extracted code to hide the title
(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);
// in document ready function call the JQ function with correct selectors. $("input").hide_my_tooltips();
Upvotes: 1
Reputation: 24815
You will need to store the error message somewhere else. For example in a JavaScript array:
var errors = { "emailformat" : "Bad email format" }
And do with it whenever you need it, call it from the array instead of from html.
Upvotes: 0