Jump to content

[SOLVED] why this script is not working for me??


naveenbj

Recommended Posts

Is there is smthing wrong in this script?

 

<script language="javascript">
function validate()
if(document.form1.username.value!='jimmy')
{
alert("Enter correct user name.");
return false;
}
if(document.form1.password.value!='123456')
{
alert("Enter correct password.");
return false;
}
return true;
}

---------------------------

here wht i want is to validate username password from predefined values.

I hope you can understand..

 

 

Regards,

Nj

 

here is the code

<html>
<head><title>admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function validate()
if(document.form1.username.value!='jimmy')
{
alert("Enter correct user name.");
return false;
}
if(document.form1.password.value!='123456')
{
alert("Enter correct password.");
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><b><font color="#666600">Admin panel</font></b></p>
<table width="34%" border="1" align="center" height="137" cellpadding="0" cellspacing="0">
  <form namme="form1" method="post" onSubmit="return validate();">
    <tr> 
      <td height="62" bgcolor="#CCCCCC"><b><font color="#990000">User name :</font></b></td>
      <td height="62" bgcolor="#CCCCCC"> 
        <input type="text" name="username">
      </td>
    </tr>
    <tr> 
      <td height="70" bgcolor="#CCCCCC"><b><font color="#990033">Password :</font></b></td>
      <td height="70" bgcolor="#CCCCCC"> 
        <input type="password" name="password">
      </td>
    </tr>
    <tr>
      <td height="26" bgcolor="#CCCCCC"> </td>
      <td height="26" bgcolor="#CCCCCC">
        <input type="submit" name="Submit">
      </td>
    </tr>
  </form>
</table>
</body>
</html>

 

Regards

Nj

your code should be , you missed out a "{" for the validate function and misspelled the name of the form

 

<html>
<head><title>admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function validate()
{
if(document.form1.username.value!='jimmy')
{
alert("Enter correct user name.");
return false;
}
if(document.form1.password.value!='123456')
{
alert("Enter correct password.");
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><b><font color="#666600">Admin panel</font></b></p>
<table width="34%" border="1" align="center" height="137" cellpadding="0" cellspacing="0">
  <form name="form1" method="post" onSubmit="return validate();">
    <tr> 
      <td height="62" bgcolor="#CCCCCC"><b><font color="#990000">User name :</font></b></td>
      <td height="62" bgcolor="#CCCCCC"> 
        <input type="text" name="username">
      </td>
    </tr>
    <tr> 
      <td height="70" bgcolor="#CCCCCC"><b><font color="#990033">Password :</font></b></td>
      <td height="70" bgcolor="#CCCCCC"> 
        <input type="password" name="password">
      </td>
    </tr>
    <tr>
      <td height="26" bgcolor="#CCCCCC"> </td>
      <td height="26" bgcolor="#CCCCCC">
        <input type="submit" name="Submit">
      </td>
    </tr>
  </form>
</table>
</body>
</html>

your code should be , you missed out a "{" for the validate function and misspelled the name of the form

 

<html>
<head><title>admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function validate()
{
if(document.form1.username.value!='jimmy')
{
alert("Enter correct user name.");
return false;
}
if(document.form1.password.value!='123456')
{
alert("Enter correct password.");
return false;
}
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><b><font color="#666600">Admin panel</font></b></p>
<table width="34%" border="1" align="center" height="137" cellpadding="0" cellspacing="0">
  <form name="form1" method="post" onSubmit="return validate();">
    <tr> 
      <td height="62" bgcolor="#CCCCCC"><b><font color="#990000">User name :</font></b></td>
      <td height="62" bgcolor="#CCCCCC"> 
        <input type="text" name="username">
      </td>
    </tr>
    <tr> 
      <td height="70" bgcolor="#CCCCCC"><b><font color="#990033">Password :</font></b></td>
      <td height="70" bgcolor="#CCCCCC"> 
        <input type="password" name="password">
      </td>
    </tr>
    <tr>
      <td height="26" bgcolor="#CCCCCC"> </td>
      <td height="26" bgcolor="#CCCCCC">
        <input type="submit" name="Submit">
      </td>
    </tr>
  </form>
</table>
</body>
</html>

 

 

 

 

Rajivgonsaves thanks a lot .

Im getting the output.

But still im not able to find out wher i was wrong??

If you can point out the particular line for me it would be gr8 help from you.

-------

Regards

Nj

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.