How do I trim a string in JavaScript? That is, how do I remove all whitespace from the beginning and the end of the string in JavaScript?
If you are using jQuery, use the jQuery.trim() function. For example:
jQuery.trim()
if( jQuery.trim(StringVariable) == '')