Reputation: 342
I am trying to call a javascript function from a Oracle MAF amx file so that only numeric keys can be entered on an input field:
<amx:inputText required="true" showRequired="true" value="#{FSRBC.selectedFSR.time}">
<amx:clientListener method="numbersOnly" type="keyDown"/>
</amx:inputText>
This calls a js function:
function numbersOnly (evt) {
var _keyCode = evt.getKeyCode();
var _filterField = evt.getCurrentTarget();
var _oldValue = _filterField.getValue();
if (_keyCode > 64 && _keyCode < 91) {
_filterField.setValue(_oldValue);
evt.cancel();
}
}
The js function is defined in its own file, validation.js which is listed in maf-feature.xml:
<adfmf:include type="JavaScript" file="resources/js/validation.js" id="i19"/>
However numbersOnly does not get called. I have added console.log and alert calls at the first line, which are not executed.
Is there anything I am missing? Thanks in advance.
Upvotes: 0
Views: 49
Reputation: 115
No need to write a separate script for the numeric keyboard. amx:inputText has a property inputType. Set "number" to it. It will show the only numeric keyboard. This property also supports email, tel, url.
Upvotes: 1