Reputation: 1639
I want to check a textarea input to see if it has at least 10 character otherwise a tooltip notification appears as info. but it does not work
I use twitter bootstrap 3
I dont want to put notification content inside HTML it should be decided by JS only.
http://jsbin.com/iVOgIxO/2/edit
HTML
<form onsubmit="return post_mta();">
<textarea name="mta" id="" cols="30" rows="10"></textarea>
<button type="submit">send</button>
</form>
JS
function post_mta()
{
var ta='textarea[name="mta"]';
if($(ta).val().length<10)
{
$(ta).tooltip({html:'at least 10 characters'});
}
return false;
}
Upvotes: 1
Views: 870
Reputation: 3061
Here is a slightly modified version that will handle the character check:
function post_mta()
{
$ta = $('textarea[name="mta"]');
if($ta.val().length<10)
{
$ta.val('at least 10 characters'); /* just for testing */
//$(this).tooltip({html:'at least 10 characters'});
return false;
}
}
However, for some reason I couldn't get the Bootstrap tooltip to render. Perhaps it may on your setup.
Upvotes: 1