-
MindGem Graphics Inc.
Textfield - Bad Language Restrictor
Hey, can I restrict a sertain string within a textfield?
if(textfield.text == *"****"*)
{
}
type of thing?....
-
I think you need to create an array (or vector) or forbidden strings and then loop to see it any is contained.
-
What's the textfield for? What kind of restriction do you want? I have 2 different kinds in mind:
-Like a chatbox kind of thing, you can see yourself type the word but it gets censored when you press enter or something.
-The instant you type the word in the textfield the word changes into stars immediately or gets cut out. Like if you press the k key to finish that 4 letter word, those 4 letters turn into stars or disappear from the textfield completely.
-
MindGem Graphics Inc.
I want to check if the textfield contains swear words and then let the user know that it's not allowed.
I know about the stars, that's for passwords and you set that up in the panel. It's not going to work in this case because it's the users choosen name in the textfield.
-
MindGem Graphics Inc.
if(textfield.text == *"swearword"*)
{
trace("you can't use swear words.");
}
That's about the thing I want...
regbolD.
But how does that work,
if you have an array it just checks if it matches the container like this
var test:Array = new Array("blah","bleh");
if(textfield.text == new[0])
{
trace("you can't use 'blah' in your name");
}
Or is it possible to check if the string contains the word like this:
if(textfield.text == *test[0]*) see what I'm aiming for?
-
You can use indexOf to determine if a substring occurs anywhere. Or you can use a regular expression to do more flexible matching. indexOf sounds like it's suitable for you.
-
MindGem Graphics Inc.
Yea, I guess I have to loop using indexOf and a bit complicated checking words using it too thinking about it.
Thanx for the reply.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|