I used the match function for regular expression.
the code I use is
if(val.match(/^s+$/) || val == "" )
but the javascript errors with
"val.match is not function"
I cant find what the problem is,
thanks in advance
I used the match function for regular expression.
the code I use is
if(val.match(/^s+$/) || val == "" )
but the javascript errors with
"val.match is not function"
I cant find what the problem is,
thanks in advance
the problem is: val is not string
i can think of two options 1) convert to string: might be a good option if you are sure val has to be string
"Same as above answer"
2) skip the line: in my case, it was better to just check the val type and skip if it is not string, because it was not a good idea to run "match" function anyways.
NOTE: making this an answer as suggested above from my comment.
Definitely make sure val is defined and a String. Also, I'm guessing it's a typo that you don't have a slash before the 's' in your regex. If that is the case you can replace your if test with "if(val.match(/^\s*$)"
I would say that val is not a string.
I get the "val.match is not function" error for the following
The error goes away if you explicitly convert to a string String(val)
And if you do use a string you don't need to do the conversion