Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(name == "swear1" ¦¦ "swear2" ¦¦ "swear3") 2

Status
Not open for further replies.

sMALLQuestions

Programmer
Mar 8, 2001
12
NZ
Hi all.
can someone tell me shy this doesn't work? and to give me acode that will work.

I want the code to detect what the user had typed in the 'name' input text feild, but i want to detect more then just one word.

on (release) {
if (name == "swear1" || "swear2" || "swear3") {
trace ("swearword detected");
} else {
trace ("thanks");
}
}


whats wrong with:

"swear1" || "swear2" || "swear3")

please help me with the code.
Thanks a bunch, in advance!
 
you have to write complete comparison statements for each thing you want to compare:

on (release) {
if (name == "swear1" || name == "swear2" || name == "swear3") {
trace ("swearword detected");
} else {
trace ("thanks");
}
}

you could always do:

if (name.substr(0,5) == "swear") {
or
if (name.indexOf("swear")!= -1 ) {


Same thing. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top