Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: [flasher] VALIDATING INPUTTED TEXT
From: Manuel S.-Harguindey
Date: Tue, 27 Feb 2001 11:24:52 -0000

Hello, this little code tests if string is a number and, if so, it
converts it to a two-decimal-digits number:

// put whatever as the string.
string = "3ytr4.665";
num = Number(string);
valid = !isNaN(string);
if (valid) {
// converts to xxx.xx
num = Math.floor(100*num)/100;
trace (string+" is a valid number.... .Converted: "+num);
} else {
trace (string+" is not a valid number.");
}

I dont know if it helps...
Manuel.

Ian Richardson escribió:

> How can i ensure that the data entered into text fields by a user is
> numerical only? ie they only enter a price
>
> Also, after a calculation, how do i ensure that the result only shows 2
> decimal places.. as in a currency?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> The Chinwag site carries a wealth of Flash resources.
> Find useful links, suggested reading and archives at:
>
> ** http://www.chinwag.com/flasher **
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> You are subscribed to flasher as: harguinatretemail [dot] es
> To unsubscribe, email leave-flasher-479908Matlists [dot] chinwag [dot] com



[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]