开发者

How to restrict the text field in actionscript 2

开发者 https://www.devze.com 2023-01-03 20:31 出处:网络
this is my code .. import RegExp; var userEmail:String; var us开发者_如何学GoerName:String; var userPhone:String;

this is my code ..

import RegExp;
var userEmail:String;
var us开发者_如何学GoerName:String;
var userPhone:String;

how to restrict my userPhone:String; to take only numbers?

i tried the restrict property. the compiler gives me error.


In ActionScript 2, the TextField.restrict property takes a String which represents a regExp like character range.

Here's a quick example of how to limit an input textfield to numbers only:

var phoneNumberLabel : TextField = createTextField("phoneNumberLabel", 1, 20, 20, 80, 20);
phoneNumberLabel.text = "Phone Number:";

var phoneNumberField : TextField = createTextField("phoneNumberField", 2, 110, 20, 200, 20);
phoneNumberField.type = "input";
phoneNumberField.border = true;
phoneNumberField.restrict = "0-9";
0

精彩评论

暂无评论...
验证码 换一张
取 消