How to check if a JavaScript string is empty or contains only spaces?
To check if a JavaScript string is empty or contains only spaces, trim the content and check if the string is empty:
var str=' ';
if (!str.trim()) {
// Do something, the string is empty or contains only spaces
}
To check if a JavaScript string is empty or contains only spaces, trim the content and check if the string is empty:
var str=' ';
if (!str.trim()) {
// Do something, the string is empty or contains only spaces
}
To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:
var str=' ';
if (!str.trim()) {
// Do something, the string is empty or contains only spaces
}
To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:
var str=' ';
if (!str.trim()) {
// Do something, the string is empty or contains only spaces
}
To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:
var str=' ';
if (!str.trim()) {
// Do something, the string is empty or contains only spaces
}
# | ID | Query | URL | Count |
---|