+ 1
How do I check for null values in JavaScript?
prompt return empty ... is this a null value?
3 Réponses
+ 5
var newVal = prompt("Enter new value:");
if (newVal === "") {
alert("user pressed OK, but the input field was empty");
} else if (newVal) {
alert("user typed something and hit OK");
} else {
alert("user hit cancel");
+ 4
if (x === null)
0
I found this on Google, but I don't want to see the "oldVal"
var oldVal = 'something';
var newVal = prompt("Enter new value:", oldVal);
if (newVal === "") {
alert("user pressed OK, but the input field was empty");
} else if (newVal) {
alert("user typed something and hit OK");
} else {
alert("user hit cancel");