Thursday, 21 June 2012

validate in javascript to check whether the string is empty or it does not containg any white space character.


to check whether the string is containg white space character only or it is blank using javascript

//it return true if the string not empty or the string not just the whitespace.
if (/\S/.test(myString)) {
    // string is not empty and not just whitespace
}

// this condition will be true if the string contain only white space or it is blank.
if ((/\S/.test(myString))==false) {
   return true if the string contains whitespace only or it is blank.
}

No comments: