I'm validating a textarea for null value by following code

var message = document.chat_frm.msg.value;
if(message=="" || message==null){
alert("Say something or shout it out! Uhm ... no, type it in!");
//document.chat_frm.msg.focus();
return false;
}

It is working fine as if without entering any text I click on submit it returns alert message but when I enter a space in textarea and then click on submit it dnt give alert message simply submits the form
Can anyone help me

Try

var message = document.chat_frm.msg.value;
.replace(/\W/g, '');

This will eliminate all characters that are neither letters, numerals nor underscores from the test. In other words, the test will only pass if there is at least one letter, numeral or underscore.

The original text in the textarea remains unaltered.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.