views:

21

answers:

1

this is my code ..

import RegExp;
var userEmail:String;
var userName:String;
var userPhone:String;

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

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

A: 

Hi TechMulla,

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";
JonnyReeves