Flex: 通过监听Event实现UI组件的Validation

Categories: Flex; Tagged with: ; @ April 23rd, 2009 14:28


textInputScore.addEventListener(Event.CHANGE, onTextInputScoreChange); // 监听Change事件
	// 检测成绩输入是否有效: 1. 必须为Number; 2. 必须小于最高分

		//if(isNaN(parseFloat(textInputScore.text))) { //错误, 形如2w之类将不报错....
		if(isNaN(Number(textInputScore.text))) {
			textInputScore.errorString = RM.getString(BUNDEL_ONLINETEST, "olt.grading.errorMessage.nan", [textInputScore.text]);
		}else if(parseFloat(textInputScore.text) > _questionAttempt.question.marksCorrrect) {
			textInputScore.errorString = RM.getString(BUNDEL_ONLINETEST, "olt.grading.errormessage.outScop", [textInputScore.text, _questionAttempt.question.marksCorrrect]);
		}else {
			textInputScore.errorString = null;
		}
	}

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.