用于数字检查的文本输入验证
我在 Flex 中看到一个奇怪的问题。我需要将所有文本输入字段重置为 0 一旦 用户提交要计算的值。在方法中
private function calculate():void {
resetToZero();
var num:Number = parseFloat(s21.text);
}
private function resetToZero():void {
//multiple if statements.... existing here..
if(s2l.text.length ==0);
{
Alert.show("length is:" + s2l.text.length);
s2l.text="0";
}
}
,当我运行程序时,我收到警报 - 长度为 1。当长度为 1 时,它是如何进入 if 语句的?这种行为确实令人困惑,需要对此进行一些说明。还有其他方法可以实现上述功能吗?
I am seeing a strange issue in flex. I need to reset all text input fields to 0 once the
user submits the values to be calculated. In the method
private function calculate():void {
resetToZero();
var num:Number = parseFloat(s21.text);
}
private function resetToZero():void {
//multiple if statements.... existing here..
if(s2l.text.length ==0);
{
Alert.show("length is:" + s2l.text.length);
s2l.text="0";
}
}
When I am running the program I am getting the alert - length is 1. How is that it when length is 1 it is entering the if statement?. The behavior is really confusing and need some light on this. Is there any other way to achieve the above functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为 IF 语句终止,
从末尾删除 ; 作为
希望有帮助
Its because of IF statement, which is terminated
Remove ; from end as
Hopes that helps