dtremblay
06-15-2006, 05:07 PM
Hi,
I would like to cancel a keyboard event, or achieve a similar result. For example, when entering numerical data, I would like to enforce that only one '.' can be entered. So, on the keydown event, I would check if a '.' is already present, and if so ignore it.
Any idea how I'd fix my code to do this?
Thanks.
<edittext resizable="false" fontsize="15" width="40" pattern="[0-9.]*" maxlength="3" text="$path{'@week'}" fontstyle="bold">
<handler name="onkeydown" args="k">
var val = this.getText().indexOf(".");
Debug.write("text:" + this.getText() + ", val:" + val);
if (val>-1){
Debug.write("Period is present");
return false;
}else{
Debug.write("Period is NOT present");
return true;
}
</handler>
</edittext>
I would like to cancel a keyboard event, or achieve a similar result. For example, when entering numerical data, I would like to enforce that only one '.' can be entered. So, on the keydown event, I would check if a '.' is already present, and if so ignore it.
Any idea how I'd fix my code to do this?
Thanks.
<edittext resizable="false" fontsize="15" width="40" pattern="[0-9.]*" maxlength="3" text="$path{'@week'}" fontstyle="bold">
<handler name="onkeydown" args="k">
var val = this.getText().indexOf(".");
Debug.write("text:" + this.getText() + ", val:" + val);
if (val>-1){
Debug.write("Period is present");
return false;
}else{
Debug.write("Period is NOT present");
return true;
}
</handler>
</edittext>