-
Mask or format TextField
Mask or format TextField
I'm using sencha touch 2:
I have a textField or numericField in a form.
I need put a mask or format like this : 9999-99999999
In the api document, I don't find the solution.
Any ideas?
{ xtype:'panel',
layout: 'hbox',
id:'panelNumero',
items:[
{
xtype: 'numberfield',
label: 'Comprobante',
name : 'comprobante',
id:'comprobante'
},
thanks in advance
-
Sencha - Senior Forum Manager
You will need to use a text field and use a keydown listener to check if the key should be allowed. Number field won't allow the '-' I believe.
-
works in browser, in simulator but there are one bug in the device (android)
works in browser, in simulator but there are one bug in the device (android)
This is the keyup listener function:
mascara:function(me, e) {
// var value = me.getValue();
if (e.browserEvent.keyCode!=8) {
var formComprobante = this.getComprobanteViewForm();
var numeroComprobante = formComprobante.getValues().comprobante;
if (numeroComprobante.length==4){
this.getComprobanteText().setValue(numeroComprobante+'-');
}
}
if (e.browserEvent.keyCode > 31 && (e.browserEvent.keyCode < 48 || e.browserEvent.keyCode > 57)) {
me.setValue(null);
return false;
}
}
works in browser, in simulator but there are one bug in the device (android):
in the device when i put the fourth character, 1234 ,
the app put the characther "-" at this moment all fine:
1234-
, but later, when I put the fifth character happens: 12345- (not correct)
this is wrong, tha app must put the "-" like this: 1234-5 (this is correct)
There are a problem with the cursor? remember: browser ok, simulator: ok, device: no.
any ideas??
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us