26 March, 2010

Restrict the input in textarea in actionscript3

Without restriction, user can input anything in the textarea.

In my internship program, users need according to the test text to input text in the textarea, after test we give them the typing speed and accuracy results.

But, user can input anything they want, even some html tags or javascript, so we need to restrict their input.

In actionscript3, there is a method of textarea to do this. For example:
var my_ta:mx.controls.TextArea;
my_ta.restrict = "^<>{}@"; 

That means user cannot input"<>{}@" these characters. "^" means characters after it are unacceptable. Without "^" means only characters in the my_ta.restrict are allowed.

No comments: