1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    javi10823 is on a distinguished road

      0  

    Default 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


  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    19
    Vote Rating
    0
    javi10823 is on a distinguished road

      0  

    Default 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??

Thread Participants: 1

Tags for this Thread