<body onload="on()">
<p>Please input a number between 1 and 10:</p>
<input type="text" id="txt" />
<input type="button" value="click" onclick="myfun()" />
<p id="demo"></p>
<script>
function myfun(){
var x, text;
var x = document.getElementById('txt').value;
if(isNaN(x)||x<1||x>10){
text = "not valid number";
}
else
{
text = "valid number"
}
document.getElementById('demo').innerHTML = text ;
}
function on(){
document.getElementById('txt').value = " ";
}
</script>
</body>
<p>Please input a number between 1 and 10:</p>
<input type="text" id="txt" />
<input type="button" value="click" onclick="myfun()" />
<p id="demo"></p>
<script>
function myfun(){
var x, text;
var x = document.getElementById('txt').value;
if(isNaN(x)||x<1||x>10){
text = "not valid number";
}
else
{
text = "valid number"
}
document.getElementById('demo').innerHTML = text ;
}
function on(){
document.getElementById('txt').value = " ";
}
</script>
</body>
No comments:
Post a Comment