I've been looking everywhere, is there any way to force show the tooltip, not using an event, but using a js code, because we all know the flaw of numerical input and the paste exploit.
<script type="text/javascript">
var previous;
//Buy Button JS code
$(function () {
$("#searchform").bind('submit', function () {
var str = $('#search-form').val();
if (str.match(/^[0-9]*$/)) {
//Great, continue executing the script.
}
else
{
//Force show a tooltip asking the user to numerically type the text.
}
});
});
I've been looking everywhere, is there any way to force show the tooltip, not using an event, but using a js code, because we all know the flaw of numerical input and the paste exploit.
<script type="text/javascript">
var previous;
//Buy Button JS code
$(function () {
$("#searchform").bind('submit', function () {
var str = $('#search-form').val();
if (str.match(/^[0-9]*$/)) {
//Great, continue executing the script.
}
else
{
//Force show a tooltip asking the user to numerically type the text.
}
});
});
Share
Improve this question
asked Mar 29, 2016 at 19:12
OmarrrioOmarrrio
1,1421 gold badge16 silver badges34 bronze badges
3 Answers
Reset to default 11To trigger a tooltip to show up you need to use the 'show'
option of the tooltip. Here is an example.
$('#element').tooltip('show')
Replace #element
with your own selector.
To add title using Jquery itself you can do this
$('#element').tooltip({title:"test title"})
To show tooltip
$('#youtooltip').tooltip('show');
Your code:
var previous;
//Buy Button JS code
$(function () {
$("#searchform").bind('submit', function () {
var str = $('#search-form').val();
if (str.match(/^[0-9]*$/)) {
//Great, continue executing the script.
}
else
{
$('#youtooltipid').tooltip('show');
// or $('.youtooltipclass').tooltip('show');
}
});
})
try
$('[data-toggle="tooltip"]').tooltip()