dc_jt Posted November 30, 2006 Share Posted November 30, 2006 HiIm looking for an equivalent to onKeyPress and onKeyDown to run the following:[quote]function CheckLength(id){ var maxLen = 250; var curContent = tinyMCE.getContent(id); var stripped = curContent.replace(/(<([^>]+)>)/ig,""); stripped = stripped.replace(/ /ig," "); var curLen = stripped.length; alert(stripped); if (curLen >= maxLen) { var msg = "You have reached your maximum limit of characters allowed"; alert(msg); //add_edit.description.value = add_edit.description.value.substring(0, maxLen); } else { document.getElementById('text_num').value = maxLen - curLen; }}[/quote]This is my field in the form:[quote]<td>Description</td><td> <textarea onKeyPress="CheckLength(this.id);" onKeyDown="CheckLength(this.id)" id="content" name=description style="width:100%; height:250;" rows="20"><?=(isset($_POST['description']))?$_POST['description']:$aListing['description']?></textarea> <input size="1" value="250" name="text_num" id="text_num"> Characters Left <input type="button" onClick="CheckLength('content')" /> </span> </td>[/quote]Hope someone can helpThanks Link to comment https://forums.phpfreaks.com/topic/28983-equivalent-to-onkeypress-and-onkeydown/ Share on other sites More sharing options...
obsidian Posted November 30, 2006 Share Posted November 30, 2006 [quote author=dc_jt link=topic=116840.msg476307#msg476307 date=1164901317]Im looking for an equivalent to onKeyPress and onKeyDown...[/quote]I'm not sure I follow. [b]Why[/b] is it that you need an equivalent? Can you describe what you're after, and maybe we can help you a little better? My first impression is that you'd need to simulate a listener to know when your focus is on the textarea. Then, you could use a global key capture to run your function only when the focus is on that element. Link to comment https://forums.phpfreaks.com/topic/28983-equivalent-to-onkeypress-and-onkeydown/#findComment-132774 Share on other sites More sharing options...
dc_jt Posted November 30, 2006 Author Share Posted November 30, 2006 Sorry I forgot to mention im looking for an equivalent to these for TinyMCE?Something like [quote]<textarea onchange="CheckLength(this.id)"[/quote] but that doesnt work ?? Link to comment https://forums.phpfreaks.com/topic/28983-equivalent-to-onkeypress-and-onkeydown/#findComment-132776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.