Skip to Content

TextField only numeric characters

Hello All,

I'm looking for a control like TextField in which I can anly enter numeric values (0123456789).

It does not seem the TextField control is able to do that.

Has anyone encountered this problem and has a solution? Or extended the TextField already for this purpose?

Any help will be appreciated.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Mar 05, 2013 at 06:44 AM


    One option would be to use the inbuilt functions of jQuery to check if the text field value is number or not. You can also use a expression to check if the field is numeric..

    I used a in-built function, and it works decently

    var oTextField = new sap.ui.commons.TextField({

    id : "id", // sap.ui.core.ID

    value : "", // string

    required : true, // boolean

    width : undefined, // sap.ui.core.CSSSize

    maxLength : 10, // int

    textAlign : sap.ui.core.TextAlign.Begin, // sap.ui.core.TextAlign

    change : [ function(oEvent) {

    //var control = oEvent.getSource();

    var oID = oTextField.getValue();


    alert("Not a number");



    alert("its a number");




    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.