【发布时间】:2018-09-04 15:35:16
【问题描述】:
我想在 TextField 中排除两个数字“3 和 4”,我试过了:
var theTextField:TextField = new TextField();
theTextField.type = TextFieldType.INPUT;
theTextField.border = true;
theTextField.x = 10;
theTextField.y = 10;
addChild(theTextField);
theTextField.restrict="0-9^3-4";
这成功排除了在文本字段中输入 3 和 4,但它也阻止了您输入 33 或 45,例如,我只想排除 3 和 4。任何包含 3 或 4 的两位或三位数字都应该被允许,知道我该怎么做吗?
【问题讨论】:
-
如果您不允许用户输入 3(复制粘贴除外),您怎么能在文本字段中输入 33?除非您事后评估文本字段的内容,而不是完全阻止该字符,否则您不能同时拥有两者。
-
放置一个运行时验证(Event.CHANGE 来自您的 TextField),如果 TextField 包含无效条目。
标签: actionscript-3 flash actionscript