View Full Version : How to force a field to be only numbers

28 Jun 2011, 10:44 AM
Hi everybody.

I have a Sencha Tuch app with a couple of forms, and some of those field should be only number.

How can i force this? That when the field gets the focus the keyboard its set to only numbers?

Thanks in advance!

28 Jun 2011, 10:48 AM
Have you tried numberfield?

xtype: 'numberfield',

28 Jun 2011, 11:10 AM
Thank you! But that places a spinner at the right of the field and for some reason it allows to input text like any other field :( I need to force the type of the field so the device shows the numeric keyboard only. Cheers!

28 Jun 2011, 11:17 AM
In a normal extjs app i can do a vtype:

Ext.apply(Ext.form.field.VTypes, {
phone: function(v) {
return /^(\d)$/;
phoneMask: /[\d]/

// .................

xtype : 'textfield',
name : 'from',
vtype : 'phone',

And of course works perfect but in the sencha touch the vtype doesn't work and i can't see how to do this...

28 Jun 2011, 11:35 AM
I dont think there is anything out of the box but you can try

1>post the fact using 'format' in validations and throwing error.
2>listen to change event and do validation/error handling