April 10, 2015

Html (Input ok )

<html>
<head>
<title>z</title>
<body>
<p>Enter something here:</p>
<input id="id1" type="number" min="100" max="300">
<button onclick="myFunction()">OK</button>
<p id="demo"> </p>
<script>
function myFunction(){
var inpObj = document.getElementById("id1");
if(inpObj.checkValidity()==false){
document.getElementById("demo").innerHTML=inpObj.validationMessage;
}
else{
document.getElementById("demo").innerHTML="InputOK!";
}
}
</script>
<p>Enter something here:</p>
<input id="id2" type="number" min="100" max="300">
<button onclick="myFunction2()">OK</button>
<p id="kahitano"> </p>
<script>
function myFunction2(){
var inpObj = document.getElementById("id2");
if(inpObj.checkValidity()==false){
document.getElementById("kahitano").innerHTML=inpObj.validationMessage;
}
else{
document.getElementById("kahitano").innerHTML="InputOK!";
}
}
</script>
</body>
</head>
</html>

No comments: