0
Please resolve me How enter "Name" with Javascript? Not applies Name to enter
Example: function myFunction( ){ var retVal=prompt("enter your name","your name here"); if(retVal === true) { document.write("what is your name?"); return true; } else { document.write("your name here:" + "retVal"); return false; } }
2 odpowiedzi
+ 2
prompt returns string entered by user or returns `null` if cancel is pressed.
You should check whether returned value is null or not (don't check against `true`)
if(retVal === null) {
//your code
}
Also don't forget to call method:
myFunction()
0
Thank you