html - javascript not working -


i new html , trying output of following prog unable output dont no whats wrong pls help...

<html> <body bgcolor="pink">     <script src="valid.js" type="text/javascript" >      </script>         <form id="frm"> <center>     <table cellspacing="10" cellpadding="10">         <tr>             <td  align="center" style="vertical-align:middle"><font size="6">login<font> </td>         </tr>          <tr>             <td  align="center" style="vertical-align:middle"><font size="4">user id <font></td><td>       :<input type="text" id="user"></td>         </tr>         <tr>             <td  align="center" style="vertical-align:middle"><font size="4">password<font></td><td>:<input type="password" id="pass"></td>          </tr>         <tr>             <td><input type="submit" value="submit" object.onclick=valid()></td>          </tr> 

and script is
function valid() {

var x=document[frm][user].value;
var y=document[frm][pass].value;
if(x===null||x==="")
{
alert("enter user id , password");
return false;
}
else
if(x==="user"||y==="password")
{
alert("user id , password correct");
return true;
}
else
alert("wrong password or user id");
}
pls trying execute above prog javascript not working

there's syntax error, due wrong closing block.

that is, } token @ line 15 wrong (you have remove it).

to avoid kind of erros, helpful being strict on code indentation, aditionally improves code readability. way, fixed , formatted code similar this:

<html>     <body>         <script type="text/javascript">          var fib1=0,fib2=1,fib=0;         var num = prompt("enter number");         if(num!=null && num>0)         {             document.write("<h1>" +num+ "fib <br/></h1>");             if(num == 1)                 document.write("<h1>" +fib1+ "</h1>");             else                 document.write("<h1>" +fib1+ " " +fib2+ "</h1>");             for(i=3;i<=num;i++)             {                 fib=fib1+fib2;                 document.write("<h1>" +fib+ "</h1>");                 fib1=fib2;                 fib2=fib;             }         }         else             alert("no proper input");         </script>     </body> </html> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -