on 2017 Feb 20 11:22 AM
Hi all,
I have an input field which should accept only numeric values from the user. I have given its type to be 'Number'. It works fine. But the problem is, it accepts the character 'e'. Is there any other way to validate this?
Here's my code:
<Input id="idlinemgr" width="100%" type="Number" value="" placeholder="Enter here" liveChange="handleLiveChange" />
Can anyone help me with this?
Thanks & Regards,
Ramya
Request clarification before answering.
inside liveChange function write below code:
var _oInput = oEvent.getSource();
var val = _oInput.getValue();
val = val.replace(/[^\d]/g, '');
_oInput.setValue(val);
hope this help.
-Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot it works fine for me
This solution doesn't prevent an input from accepting non-digits - the character is accepted and then later removed.
For example if you've got the value bound to a model and there's an event registered on the binding or on the model then they will get fired twice.
A better solution is to use an event delegate on keypress.
User | Count |
---|---|
34 | |
21 | |
14 | |
8 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.