Hello Reader's if you are making the validation of text box to set it's max and min range, Then by using javascript you can do it faster.
Lets see the example as below:-
<!DOCTYPE html>
<html>
<body>
<p>Enter a number and click OK:</p>
<input id="id1" type="number" min="30" max="900">
<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 = "Input OK";
}
}
</script>
</body>
</html>
Now everytime if user type less than 30 characters the output message of validation will show like this:-
Output:-
<pre>Please type more than 30 characters
And if user type more than 900 characters then the output message of validation will show like this:-
Please type less than 900 characters
0 Comment(s)