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 Respuestas
+ 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;
}