0

I try to show two different title for the Tooltip (Bootstrap) and a standard html validation forms.

Sample code to http://jsfiddle.net/00kvznLu/

<form data-toggle="validator" role="form" class='containter'>    
  <div class="form-group">
    <label for="inputTwitter" class="control-label">Twitter</label>
    <div class="input-group">
      <span class="input-group-addon">@</span>
      <input type="text" data-toggle="tooltip" title="Do it here..." pattern="^([_A-z0-9]){3,}$" maxlength="20" class="form-control" id="inputTwitter" placeholder="1000hz" required>
    </div>
  </div>
  <div class="form-group">
    <input type="submit" value="Check Form">
  </div>
</form> 

But for some reason, I do not Tooltip displays as well as on http://getbootstrap.com/javascript/#tooltips

Is it possible to make so that when you move the computer mouse was shown title = "messages1", and the derivation of error "pattern" to the standard message "Enter the data in the specified format." added title = "messages2"?

Is it possible to do like this tooltip-title="messages1" and error-pattern-title="messages2"?

Bootstrap Tooltip:

title 1

Error message:

title 2

Update 1: Added data-title="Custom Title"

<input type="text" data-toggle="tooltip" pattern="^([_A-z0-9]){3,}$" maxlength="20" class="form-control" data-title="Custom Title" title="Do it here.." id="inputTwitter" placeholder="1000hz" required>
Kolya_Net
  • 1,050
  • 3
  • 13
  • 25
  • Do you mean change the tooltip if the form isn't valid on submission? – StudioTime Mar 25 '16 at 07:53
  • @DarrenSweeney I want to display two different messages in two different places (added image, I hope it will be clear). – Kolya_Net Mar 25 '16 at 08:09
  • is this ok? http://jsfiddle.net/00kvznLu/1/ – Rajshekar Reddy Mar 25 '16 at 08:11
  • @Reddy in your code you have corrected display Tooltip, but the message is no longer displayed along with an error message (the second image circled in red) – Kolya_Net Mar 25 '16 at 08:22
  • @Kolya_Net let me know if my answer helps. – Rajshekar Reddy Mar 25 '16 at 08:39
  • @Reddy Almost all true. Added data attribute http://jsfiddle.net/e278e33w/ I got what I wanted. Would you change your answer, then I have it confirmed. – Kolya_Net Mar 25 '16 at 09:51
  • @Kolya_Net sure but why selecting from the data attribute, It will affect your entire site which has that attribute. I suggest using the Id to apply the tooltip as it will target only that element. But if you want to target many other elements then a class selector would be best choice. Only if you want your entire site to have the tooltip title same as this input title then what you suggest works. But I recon that's not what you want. right?? – Rajshekar Reddy Mar 25 '16 at 09:57
  • @Kolya_Net I got your point. But do consider my explanation too. :) – Rajshekar Reddy Mar 25 '16 at 09:58

2 Answers2

1

use the below script. Trick is to apply a tooltip to the parent tag of the input. Let me know if this helps. Working Fiddle

$(function () {
  $('#inputTwitter').parent().tooltip({
   title : $('#inputTwitter').data('title')
  });
})
Rajshekar Reddy
  • 18,647
  • 3
  • 40
  • 59
0

You can set it like this:

var newValue = 'This is a new message';
$(tooltip-selector).attr('title', newValue)
    .tooltip('fixTitle')
    .tooltip('show');

I suggest you to use data-original-title instead of title Fiddle here

Check @Mehmet Duran answer

Community
  • 1
  • 1
Yuri
  • 3,082
  • 3
  • 28
  • 47