cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HTML5's pattern using sap.m.Input

Former Member
0 Kudos

I've looked in the SAPUI5 API Reference and I googled for this but there's no info on how to implement pattern.  Though my Input is set to type Number,  it's allowing the user to enter '@', '&'.

Is there any way to implement pattern for this Input object?  Thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Jay,

This can be done as follows,

var seatNumber = new sap.m.Input( { value : "Some Dummy Value",

type : sap.m.InputType.Number } )

Now, this sap.m.Input will accept only numbers.

Happy coding.

Regards,

Suraj Kumar

Former Member
0 Kudos

Thanks Suraj.  The SDK version I have is still 1.16.  With the type explicitly set to Number, it is still allowing these characters.

I did use isNaN to handle this issue.  Maybe the new SDK may have fixed this.  Thanks again for the reply.

former_member184867
Active Contributor
0 Kudos

You can enforce an integer or float type input using type system. Please refer to  OpenUI5 SDK - Demo Kit . Working example here Data binding test page with Data Types

yesrajkumar
Active Participant
0 Kudos

Hi,

Try this,

var app = new sap.m.Input("Input");

  

var oButton1 = new sap.ui.commons.Button({

  text : "Button",

  press : function() {

    //Allow only alphanumeric characters 

     var mailregex = /^[a-zA-Z0-9]*$/;

     if (!app.getValue().match(mailregex)) {

       

       alert('Special Characters : ' + app.getValue() + ' not allowed ');

      }

     

      }

});

// attach it to some element in the page

  app.placeAt('content');

  oButton1.placeAt("content");

Thanks,

S.Rajkumar.