Building an regular expression that will reject an input string which contain spaces.
I have a following expression, but its not working as well;
^[
You may use \S
\S
\S matches any non white space character
Regex
/^\S+$/
Example
function CheckValid(str){ re = /^\S+$/ return re.test(str) } console.log(CheckValid("sasa sasa")) console.log(CheckValid("sasa/sasa")) console.log(CheckValid("sas&2a/sasa"))