求救:htc 事件问题 (在线苦等,谢谢)
我写了一个限制只能输入数字的htc组件如下:
奇怪:关于<public:attach event="onkeypress" onevent="check()" />就好使
而 <public:attach event="onchange" onevent="recheck()" />就不好使!
具体代码如下:
<public:component>
<public:property name="allowNegative" />
<public:property name="allowDecimal" />
<public:property name="precision" />
<public:property name="scale" />
<public:property name="minValue" />
<public:property name="maxValue" />
<public:attach event="ondocumentready" onevent="DoInit()" />
<public:attach event="onkeypress" onevent="check()" />
<public:attach event="onchange" onevent="recheck()" />
<script language="javascript">
var input = element;
function DoInit(){
this.textbox = document.createElement("input");
this.textbox.type = "text";
this.textbox.value = "";
element.insertAdjacentElement("beforeEnd",this.textbox);
this.textbox.style.backgroundColor = "#CCFFCC"
}
function check(){
alert('aaaaa');
this.allowNegative = (allowNegative)?allowNegative:true;
this.allowDecimal = (allowDecimal)?allowDecimal:true;
//pressKeyNumberBox(input,allowNegative,allowDecimal);
}
function recheck(){
alert("bbbb");
this.allowNegative = (allowNegative)?allowNegative:true;
this.precision = (precision)?precision:15;
this.scale = (scale)?scale:0;
this.minValue = (minValue)?minValue:1;
this.maxValue = (maxValue)?maxValue:8;
//validateNumber(input, allowNegative, precision, scale, minValue, maxValue);
}
</script>
</public:component>