Validate an input field with minimum and maximum values : TextField : Form Control JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Form Control » TextField »

 

Validate an input field with minimum and maximum values



<html>

<head>
<script type="text/javascript">
    function validate(){
        x=document.myForm
        txt=x.myInput.value
        if (txt>=&& txt<=5) {
            return true
        }else{
            alert("Must be between 1 and 5")
            return false
        }
}
</script>
</head>

<body>
    <form name="myForm" action="http://www.navioo.com" onsubmit="return validate()">
    Enter a value from to 5
    <input type="text" name="myInput" size="20">
    <input type="submit" value="Submit">
</form>
</body>

</html>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Form Control
» TextField