How to make an alert if the user inputs nothing else. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to make an alert if the user inputs nothing else.

if the user doesn't input anything then how to make alert in js.

7th May 2018, 3:43 PM
keev23i
keev23i - avatar
3 Answers
0
function hello(){ var input=prompt("enter your name"); if(input===""){ alert("enter a valid name"); } else{ document.write("hi "+input); } }
7th May 2018, 4:08 PM
Roel
Roel - avatar
- 1
why js use <input type="text" name="whatever" required> i wont be able to submit until wrote anything into it
7th May 2018, 3:59 PM
Lexfuturorum
Lexfuturorum - avatar
- 1
but to answere your question alert("whaterver you wanna alert him to do");
7th May 2018, 4:01 PM
Lexfuturorum
Lexfuturorum - avatar