Skip to Content
0

How to restrict input control to certain length when type is number?

May 30, 2017 at 06:51 AM

48

avatar image
Former Member

maxlength property is not working

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

1 Answer

Best Answer
avatar image
Former Member May 31, 2017 at 07:34 AM
0

Hi

This works fine,

View.xml

<Input id="inputId" maxLength="5">

Controller.js

this.getView().byId("inputId").attachBrowserEvent("keypress",function(e){

var mphone_code=[48,49,50,51,52,53,54,55,56,57,32];
if(!($.inArray(e.which,mphone_code)>=0)){
e.preventDefault();
}
})

Regards,

Chethan RK

Share
10 |10000 characters needed characters left characters exceeded