A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: limit input to numbers... FLASH 5!

  1. #1

    limit input to numbers... FLASH 5!

    I'm working on a tool for a client. This client wants the tool to run as a flash 5 swf... Now, I would like to have an input field where users input a number... so I want to prevent them from typing in letters and what else. Since we're talking flash 5 here, I can't use the instancename.restrict function because textfields can't have instance names in FL5. Also, the option of just embedding the numbers is no good either because there's other input fields which use the same font and require letters (thus enabling letters in the number field as well).

    Surely there's an easy way to get the input field limited to numbers? And don't tell me to tell the client just to go for flash mx, they won't buy it (despite the figures).

    hope someone can help.

  2. #2
    I've figured out a work around. I'll post it for anyone who might run into this problem as well.

    I can't, so far, prevent a user from filling in letters. However, there's an easy way to evaluate the input. This by simply setting a range of numbers which are 'good'.. that means that the rest (including letters and other gunk) will not meet the requirement.

    for example:

    on(release){
    if(inputValue1 >= 0 and inputValue1 < 20){
    _root.vars.inputValue1 = inputValue1
    play();
    }else{
    inputValue1 = "error"
    }
    }


    <edit>You could, I think, also just put a min or max, e.g. only >=0</edit>

  3. #3
    Senior Moment
    Join Date
    Mar 2004
    Location
    MN, USA
    Posts
    369
    if(isNaN(inputValue1){
    inputValue1 = "error"
    }

    ...or something like that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center