Regex to check if whitespace present?
If you want to match something there, but no whitespace:
alert(/^\S+$/.test(value));
You don't need the brackets, you would need to escape the backslash (if using the string form) and the built-in regex syntax is easier because you don't have to escape backslashes when using the built-in regex syntax.
var inValid = /\s/;
var value = "test space";
var k = inValid.test(value);
alert(k);
You need to escape the backslash if you are creating your RegExp object from a string literal:
var inValid = new RegExp("[\\s]");
Alternatively you can just use the following:
var inValid = /\s/;
This uses a regular expression literal so the escaping of the backslash is not necessary, and there is no need for the character class here so I dropped the square brackets as well.