cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

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

former_member195820
Participant
0 Kudos
32,599

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

View Entire Topic
jacek_wojciechowski
Discoverer
0 Kudos

You can prevent an Input from accepting chars that are not digits by adding an event delegate on keypress:

oInput.addEventDelegate({
  onkeypress: function(oEvent) {
    if (oEvent.key < '0' || oEvent.key > '9') {
      oEvent.preventDefault()
    }
  }
})