Created
March 11, 2016 01:43
-
-
Save MuratOrs/9aaca0f5d7a281cb090a to your computer and use it in GitHub Desktop.
Валидация данных в HTML форме
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Javascript</title> | |
</head> | |
<body> | |
<p>введите число от 1 до 99</p> | |
<input id="number" type="text" > | |
<button type="button" onclick="myFunction()">Проверить</button> | |
<p id="result"></p> | |
<script> | |
function myFunction(){ | |
var number, result; | |
number = document.getElementById('number').value; | |
if (isNaN(number) || number < 1 || number > 99){ | |
result = 'Число неверно'; | |
} else { | |
result = 'Число верно'; | |
} | |
document.getElementById('result').innerHTML = result; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment