as3 textarea component: disallow user to enter a line break

﹥>﹥吖頭↗ 提交于 2019-12-11 08:29:05

问题


Hy I'm trying to prevent the user to enter any form of line breaks in a as3 textarea component.

I tried using the restrict param of the textarea like this:

foo.restrict = "^/\r\n//\n/"

but i don't have any success.

Hope anybody can help me out on the correct way to do this.

thanks in advance Milan


回答1:


I don't think you can do that. The workaround is replacing cartridge return with empty string in the CHANGE event.

import flash.events.*;

foo.addEventListener(Event.CHANGE, test_change);

function test_change(e:Event)
{
    foo.text = foo.text.replace("\r", "");
}


来源:https://stackoverflow.com/questions/1239891/as3-textarea-component-disallow-user-to-enter-a-line-break

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!