• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Restrict Textinput

Is it possible to do a global restrict on all textinput

something simular to a global style except i want  to restrict all textinputs i have, a lot, to all allow the same set of keys
0
jockmahon01
Asked:
jockmahon01
1 Solution
 
wal_toorCommented:
whell, there is no global way of doing this. But there is a way to do this in a recursive loop. You loop through all instances on the stage/root, and then check if the instance is a textfield. Now you can set the text restriction on this textfield (even without instance names). With this loop even deeply nested textfields are restricted.

I have tested this script on textfields nested 3 levels deep, and it worked.

Hope this works for you.

greetz,
walter


restrict = function(objField){
	for(i in objField){
		if(objField[i] instanceof TextField)objField[i].restrict = "0-9"; // restricts to numbers
		if(objField[i] instanceof MovieClip)restrict(objField[i]);
	}
}
restrict(_root);

Open in new window

0
 
jockmahon01Author Commented:
kewl that pretty good, cheers i dont use the timeline all my forms are movieclips in the lib but im sure i can use the instanceof, i had taught of the same thin but was using typeof and was only returning "movieClip"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now