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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.