+ 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 Respostas
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