Click here to Skip to main content
15,885,146 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HTML
<html>
<head>
<title>Login page
</title>
<script>
fuction test()
{
var x=document.getElementById('fname').value;
alert(x+ " ");
if(x.length !=8 )
{
alert("user name should contain 8 characters");
}
else
{
window.location.assign("test.html");
}
}
</script>
</head>
<body>
<form  name="login" method="post" onsubmit="test.html">
Enter name <input type="text" id="fname" />
enter password<input type="password" id="pwd"/>
<input type="submit" value="login"/>
</form>
</body>
</html>



and the code for test.html is just a crap(i mean just as normal page :P)
i was waiting for someone who could help me out.
when the username and password are equal to 8 characters then the test.html page should open!!
looking forward
Posted
Updated 23-Dec-15 23:58pm
v2
Comments
Raje_ 24-Dec-15 6:21am    
Do you wanna open test.html page as a pop up or simply you want to redirect to this page?

1 solution

Here is one example :

javascript code :

function test() {
           var x = document.getElementById('fname').value;
           var y = document.getElementById('pwd').value;
           alert(x.length + '  ' + y.length);
           if ((x.length > 8) && (y.length > 8)) {
               document.getElementById('form1').submit();
               return true;
           }
           else {
               alert("user name should contain 8 characters");
               return false;
           }
       }


Html code :
<form id="form1" runat="server" method="get" action="test.htm">
Enter name
   <input type="text" id="fname" />
   enter password<input type="password" id="pwd" />
   <input type="submit" value="login" onclick="return test();" />
   </form>


good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900