capypara
01-23-2012, 11:17 AM
Hi all, as the title says i am trying to keep count of the number of words a user has typed into a textbox.
I have an emoticon box, something like the one that you see when you reply/start a thread here. The mouseup event fires off when the user clicks on an emoticon to display it in the textbox.
The problem here is, my code below does not start counting if an emoticon is added when theres nothing in the textbox (making the emoticon the first item). I can continue to add more smileys in and they will be counted in the word limit, but the first one will not be included in the count, unless the user clicks somewhere on the screen. How can i fix this problem?
//#message is the textbox
$(document).ready(function()
{
var characters = 100;
$("#remainder").append(characters+"words left");
$("#emoticonsbox").mouseup(function()
{
var remaining = characters - $("#message").val().length;
$("#remainder").html(remaining+"words left");
});
});
I have an emoticon box, something like the one that you see when you reply/start a thread here. The mouseup event fires off when the user clicks on an emoticon to display it in the textbox.
The problem here is, my code below does not start counting if an emoticon is added when theres nothing in the textbox (making the emoticon the first item). I can continue to add more smileys in and they will be counted in the word limit, but the first one will not be included in the count, unless the user clicks somewhere on the screen. How can i fix this problem?
//#message is the textbox
$(document).ready(function()
{
var characters = 100;
$("#remainder").append(characters+"words left");
$("#emoticonsbox").mouseup(function()
{
var remaining = characters - $("#message").val().length;
$("#remainder").html(remaining+"words left");
});
});