Solved

what is wrong with this code?

Posted on 2011-09-07
4
151 Views
Last Modified: 2012-05-12
<!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>
0
Comment
Question by:costaf
  • 2
4 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 36496204
What are you trying to accomplish and what is the code currently doing?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36496288
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

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36496301
working test page : http://jsfiddle.net/vK856/
0
 
LVL 2

Author Closing Comment

by:costaf
ID: 36496470
thx u all
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to hide html tags in text area 4 37
what is the difference between call and apply 1 26
Sorting a string 1 17
maps stopped work unsure why 7 5
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now