I\'m trying to check if a form input has any value (doesn\'t matter what the value is) so that I can append the value to the action URL on submit if it does exist. I need t
var val = document.getElementById('p').value;
if (/^\s*$/.test(val)){
//value is either empty or contains whitespace characters
//do not append the value
}
else{
//code for appending the value to url
}
P.S.: Its better than checking against value.length because ' '.length = 3.