hello! i want some feedback and remarks about my JS

They have: 44 posts

Joined: Jul 1999

i seeked for a good js which will check a form.(which connect to DB)
i didn't find any..so i build one myself...
i think maybe it not good enogh...
can you guys take a look and tell me what i can fix or make better>?!
thank you anywho...
function chk()
{
var xxx="!@#$%^&*(){}[]|'?/><~`" // the bad string...
var obj = new Array
for (W=0;W<document.form1.length;W++)
// putting the FORM array in an obj
{
var ok=true // wheter is true
var i=0 //index
obj[W]=document.form1[W].value
len=obj[W].length
while (ok==true)
{
for (j=0;j<len;j++)
{
if ( xxx.indexOf(obj[W].charAt(j))!=-1 )
{
ok=false
j=len; W=100 // stupid - but enough
alert("ëúåá ø÷ ñéîðéí çå÷ééí áá÷ùä")
} // end of the IF
} // end of the small for
if (i<=len) i++
else ok=false
} // end of the while
}// end of the big for
}// end of function
//-->
</script>

------------------
I bet you never been in this site before...
Deja~vu

I bet you never been in this site before...
Deja~vu

They have: 297 posts

Joined: Apr 1999

It would help to know what it is that you want to check. Numbers, characters, @ sings for eMail...

Also, please format your code like this

someStatement {
someStatement {
soemStatement {
....
}
}
}

That way it will be a lot easier to read.

Thank You,

Malte

------------------
Malte Ubl - www.Boardzilla.org
Communication: public<->programmers
of the Boardzilla BB

They have: 44 posts

Joined: Jul 1999

well...
(1)
i want to check only if the user put the chars i wrote in the top of the code.
(it's to keep the ASP and SQl "clear"...)
(2)
about the {}.
i code like that:
function gh()
{
something else
{

}
}
so when i copyed and paste it showd what it showd...

if you have the time and patience you can just copy to notepad and then it will be more readble...
bye.

------------------
I bet you never been in this site before...
Deja~vu

I bet you never been in this site before...
Deja~vu

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi Tsalim,

if you are simply checking to see if the user has input any of the characters in var xxx (and I think that is what the code does) and then issue an alert, Why are you creating and filling an extra array?
Why not....

xxx = "blahblah"
len = document.formName.length
with (document.formName)
{
for (i = 0; i < len ; i++) // make it len -1 if you have a button
{
if( xxx.indexOf(obj[W].charAt(elements[i].value))!=-1 )
blahblahblah

Vinny GrassBlade:cut&paste javascript

Where the world once stood
the blades of grass cut me still

They have: 44 posts

Joined: Jul 1999

you right.
thank you.

------------------
I bet you never been in this site before...
Deja~vu

Jack Michaelson's picture

He has: 1,733 posts

Joined: Dec 1999

Since you're using ASP, why not use the standard ASP-validation, which is actually quite simple??

Jack.

They have: 44 posts

Joined: Jul 1999

what do you mean?!
to do it in VBS?! - i want it to be fast...
or there is another way,a bulit in way?!?!

------------------
I bet you never been in this site before...
Deja~vu

I bet you never been in this site before...
Deja~vu

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.