Problem with string???

They have: 9 posts

Joined: Jun 2000

Hi,
I would like to check a string to verify that there is no
special caracters like : "*","\","/","|", and more...

I use the fonction mystring.search(x), with x the special caracter (like *).

It doesn't work because x must be a string and * is an operator.

I don't manage to change it to a string!!!

Any ideas???

Thanks a lot.

Gauthier

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

What language? Javascript?

I'm not a javascript guru (by far), but try escaping the characters...
mystring.search(\x)

good luck,

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

You could define your characters within a string.

var badChars = '()?|\/*';
data = "2d434/";
for (i = 0; i < data.length; i++)
if (badChars.indexOf(data.substring(i, i+1)) != "-1")
alert(data.substring(i,i+1));

Vinny

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

They have: 1,587 posts

Joined: Mar 1999

anybody got a clue why this javascript want work? i didn't include the script tags and beginning and end of the code here.

it's supposed to parse a tracking url, like http://www.whatever.com?Bob

so that Bob would be printed out.

var URLString = window.location;
var start = URLString.indexOf("?");
var end = URLString.length;
var userName = URLString.substring(start,end);
document.write(userName);

Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?

They have: 1,587 posts

Joined: Mar 1999

oops, sorry for the above, thought i was posting a new topic. Smiling

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.