I know I can use the following to check if a string is empty in JavaScript:
if(Message != '')
How would I check to see if a string ‘Message’ in this case – is empty and doesn’t contain a number of spaces. eg:
' '
would I need to use regular expressions?
jQuery doesn’t replace Javascript.
You can use:
Having said that, if you really want jQuery version, try this:
Or, so long as you’re only targeting IE9+ and modern browsers, you can use the built in trim function.