Link to home
Start Free TrialLog in
Avatar of costaf
costafFlag for Portugal

asked on

what is wrong with this code?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>testeeeee</title>

<script language="JavaScript" type="text/javascript">

<!--

var st="!#ana@.$";

function f1(info,s)
{
for(var i=0;i<info.length;i++)
{
if (s.indexOf(info.charAt(i))==1)
{
return (true);
}
 }
 return(false);
 }
 if(f1(document.forms[0].elements[0].value,st)==true)
 {
 alert("xyz");
 }
 else{alert("abc"); }
 

//-->
</script>
</head>
<body>
</body>
</html>
Avatar of strickdd
strickdd
Flag of United States of America image

What are you trying to accomplish and what is the code currently doing?
Avatar of leakim971
first look, there's not FORM element so you CAN'T USE  : forms[0]

should be good to wiat total page loading with something like :

window.onload = function() { // your code here }


var st="!#ana@.$";

function f1(info,s) {
    for(var i=0;i<info.length;i++)
    {
        if (s.indexOf(info.charAt(i))==1)
        {
            return (true);
        }
     }
     return(false);
}

window.onload = function() {
    if(f1(document.forms[0].elements[0].value,st)==true)
    {
        alert("xyz");
    }
    else
    {
        alert("abc");
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of costaf

ASKER

thx u all