Skip to Content
0

How to make input field accept only numeric values in sapui5 using XML?

Feb 20, 2017 at 11:22 AM

1.2k

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Pierre Dominique Feb 20, 2017 at 01:24 PM
0

Hi,

This is the expected behaviour so that the user can enter something like 1e5 instead of 100000 for instance. You should probably not change this but if you really want to do it, you can use jQuery to achieve this: http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery/995193#995193

Cheers,

Pierre

Share
10 |10000 characters needed characters left characters exceeded
Akhilesh Upadhyay Feb 20, 2017 at 01:28 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded