开发者

do not allow the user to enter zero's with decimal in the flex text input box

开发者 https://www.devze.com 2023-02-07 17:15 出处:网络
i have a text input box in flex. i wanted to call a function if the text of text input box is >0. i have parsed the text into integer ,parseInt(str.text) where str.text is 0.03(something like this) th

i have a text input box in flex. i wanted to call a function if the text of text input box is >0. i have parsed the text into integer ,parseInt(str.text) where str.text is 0.03(something like this) then it becomes zero, as i am parsing into integer.

any hel开发者_JS百科p is appreciated.


Just do Number(str.text), that will give you a float. Use isNaN() to check if it's actually a number that was parsed.


var n:Number = Number(textInput.text);
if (!isNaN(n)) {
  // do whatever
}


i have done it like below parseFloat(str.text)>0 { // statements; } so thts if user enters 0.00 or 00.00 or 00000.0 or 000.000 it will not allow , if he enters 0.01 or 0.89 or anything greater than zero will be allowed. Anyway thanks for the response.

0

精彩评论

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