0
Including if statement
I want my code below to return false and alert the user if they input a username that contains a space. How would you write it? if(username INCLUDES â â){ alert(ââ) return false; } sorry if the title is phrased oddly, I didnât know how to say it. https://code.sololearn.com/WtcEEjQV6VOf/?ref=app
3 Answers
+ 3
Try to add:
if(username.indexOf(" ")!==-1) {
alert("Username must not contain spacing.");
return false;
}
https://code.sololearn.com/WWK6ulX3vhdX/?ref=app
+ 1
CalviŐ˛ Very brilliant soln
0
Try this:
if(username.match(/\s/) != null){
alert("")
return false;
}