1) I have javascript

2) I need to limit it only to input numbers.

3) I need to disable blank confirmation.

function checkAge(age) { if (age > 18) { return true; } else{ return confirm('Родители разрешили?'); } } var age = prompt('Ваш возраст?'); if (checkAge(age)) { window.location="2"; alert( 'Доступ разрешен' ); } else { window.location="3"; alert( 'В доступе отказано'); } 

    1 answer 1

     var str = prompt("введите строку"); var re = /^[0-9]+$/g if (re.test(str)) alert("верно"); else alert("не верно"); 

    • + instead of * will relieve you from checking the string for emptiness - Grundy
    • @Grundy, did not know, thank you. - perfect