i have a problem with conditions of typed text in prompt. I want to add conditions for prompt. Case A : If you type nothing in prompt - it will alert that you have inserted nothing. and opens prompt again until you type the number in. Case B: if you type text - it will alert that you haven't inserted number. and opens prompt again until you type the number in as in case A Case C: if you type number (What is essential, because it is a script which calculate the cubic equal) - it continues the script.
This script only finds out when you type nothing and press enter - It will alert you that you havent typed anything - BUT it will tell you even if you type number in - Which totally breaks the script.
And I also don't know how to define number in JS - How to find out when someone types in prompt for example "Word" - that is not a number, so again it suppose to tell you that you havent inserted number.
var a = prompt('Zadejte hodnotu a v kvadratické rovnici ax2 + bx + c = 0');
if (a == "") do {
alert('Nezadali jste žádné číslo, zadejte ho prosím');
a = prompt('Zadejte hodnotu a v kvadratické rovnici ax2 + bx + c = 0');
}
while (a = "something");
var b = prompt('Zadejte hodnotu b v kvadratické rovnici ax2 + bx + c = 0');
if (b == "") do {
alert('Nezadali jste žádné číslo, zadejte ho prosím');
b = prompt('Zadejte hodnotu b v kvadratické rovnici ax2 + bx + c = 0');
}
while (b = "something");
var c = prompt('Zadejte hodnotu c v kvadratické rovnici ax2 + bx + c = 0');
if (c == "") do {
alert('Nezadali jste žádné číslo, zadejte ho prosím');
c = prompt('Zadejte hodnotu c v kvadratické rovnici ax2 + bx + c = 0');
}
while (c = "Something");
Thanks a lot!