MyBB Community Forums

Full Version: Please help to fix this JavaScript!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Guys is there a way to make this code not to count blank spaces only characters.

And if it's possible not to count BBcode?

Here is the code because many say I don't want to share my code with this community!

Event.observe(window, 'load', function (min) {
	if($('message_new')) {
	var elTextarea      = $('message_new');
	} else {
	var elTextarea      = $('message');
	}

	var elCountStart   = $$('.countstart').first();
	var minLength       = Number(minchars);
	var space = 0;
	
	elCountStart.innerHTML = 0;

	elTextarea.observe('keyup', function ()  {  
	
		if(elTextarea.value.match(/\s/g,''))  {
			space = elTextarea.value.match(/\s/g,'').length;
			if( elTextarea.value.length >= space ) { 
				charas = elTextarea.value.length;
			}
		} else {
			charas = elTextarea.value.length;
		}
          
		elCountStart.innerHTML = + Number( charas );

	})

});



And this one too:
<script type="text/javascript">
function countit(what){
formcontent=what.form.subject.value;
what.form.displaycount.value=formcontent.length;
}
</script>