Hi There,
Really stuck on the following validation,
I have a text box where the user enters just two characters however my validation is not working
var x=document.forms["myForm"]["age"].value;
if((x < 2) || (x > 2))var x=document.forms["myForm"]["age"].value;
if((x < 2) || (x > 2))
Help![]()
Code:<!DOCTYPE html> <html> <head> <script> function validateForm() { var x=document.forms["myForm"]["fname"].value; if (x==null || x=="") { alert("First name must be filled out"); //document.getElementById('Firstname').style.color="red"; return false; } // for the the validation to work var x=document.forms["myForm"]["lname"].value; if (x==null || x=="") { alert("Last name must be filled out"); return false; } // for the validation to work var x=document.forms["myForm"]["age"].value; if((x < 2) || (x > 2)) { alert("must be two numbers"); return false; } // for the validation to work } </script> </head> <form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post"> <td id="Firstname">Firstname</td> <input type="text" name="fname"></P> <P>LastName: <input type="text" name="lname"></P> <P>Enter your Age: <INPUT TYPE="Age" NAME="age" ></P> <input type="submit" value="Submit"> </form> </body> </html>




