Need to check blank value... spaces added with spacebar without any text...triming not working.

I want to check that weather any data entered in editor or not. I got value in java script by this function:
var txtMsgValue = dojo.widget.byId('newsdisplay').getEditorContent();

And checking that
if(txtMsgValue == null || txtMsgValue == '') {
alert ("Message is requird for mail.");
Return false;
}
it works fine it nothing entered in editor but if i entered only blank space by 'spacebar', it doesn't check. It gives me correct length... (Means correct count of how many spaces I entered)... But when I tried to trim that... by this function:
txtMsgValue = txtMsgValue.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
It doesn’t work. It just trimmed only 1 blank space.
Please give me solution, I desperately need that.
Thanks in advance.

try dojo.string.trim()

Try using dojo.string.trim().

dojo.require("dojo.string");
var txtMsgValue = dojo.string.trim(dojo.widget.byId('newsdisplay').getEditorContent());

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options