Created
October 11, 2014 15:44
-
-
Save ryanorsinger/177ca51642d1bac231f0 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/heluke/2
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
<p>Please input a number between 1 and 10:</p> | |
<input id="numb" type="text"> | |
<button type="button" onclick="myFunction()">Submit</button> | |
<p id="demo"></p> | |
<script id="jsbin-javascript"> | |
function myFunction() { | |
var x, text; | |
// Get the value of input field with id="numb" | |
x = document.getElementById("numb").value; | |
// If x is Not a Number or less than one or greater than 10 | |
if (isNaN(x) || x < 1 || x > 10) { | |
text = "Input not valid"; | |
} else { | |
text = "Input OK"; | |
} | |
document.getElementById("demo").innerHTML = text; | |
} | |
</script> | |
<script id="jsbin-source-html" type="text/html"><p>Please input a number between 1 and 10:</p> | |
<input id="numb" type="text"> | |
<button type="button" onclick="myFunction()">Submit</button> | |
<p id="demo"></p> | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function myFunction() { | |
var x, text; | |
// Get the value of input field with id="numb" | |
x = document.getElementById("numb").value; | |
// If x is Not a Number or less than one or greater than 10 | |
if (isNaN(x) || x < 1 || x > 10) { | |
text = "Input not valid"; | |
} else { | |
text = "Input OK"; | |
} | |
document.getElementById("demo").innerHTML = text; | |
}</script> |
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
function myFunction() { | |
var x, text; | |
// Get the value of input field with id="numb" | |
x = document.getElementById("numb").value; | |
// If x is Not a Number or less than one or greater than 10 | |
if (isNaN(x) || x < 1 || x > 10) { | |
text = "Input not valid"; | |
} else { | |
text = "Input OK"; | |
} | |
document.getElementById("demo").innerHTML = text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment