To avoid typing multiple spaces in text area I’m calling a function on onCLick, on keyup and written the code below
var val = document.getelemntByID('trmp');
val.value = val .value.replace(/ +(?= )/g,'');
this is working fine in Firefox, in IE7 it’s working, but causing some other problem, like select a word and delete it will delete entire text area content
Use the regex only for space.Add a keycode condition.
Check this fiddle http://jsfiddle.net/hikki/FNJmE/