1. #101
    Sencha User
    Join Date
    Apr 2008
    Posts
    80
    Vote Rating
    0
    g13013 is on a distinguished road

      0  

    Default


    i think that my extention is better solution for you
    http://www.extjs.com/forum/showthread.php?t=63051

  2. #102
    Ext User
    Join Date
    Apr 2010
    Posts
    1
    Vote Rating
    0
    cpvaishya is on a distinguished road

      0  

    Default Changing the mask dynamically

    Changing the mask dynamically


    Hi,

    I need to change the mask of an existing field based on value from database.
    So, basically the same textfield can have different mask based on database.

    Is this possible with this plugin?
    I was able to apply a static mask to the textfield, but am not able to change it dynamically.

    Regards,
    Chintan

  3. #103
    Ext User dandfra's Avatar
    Join Date
    Jun 2007
    Location
    Trento, Italy
    Posts
    122
    Vote Rating
    0
    dandfra is on a distinguished road

      0  

    Default @AMcpvaishya

    @AMcpvaishya


    Not in the current state....

    But I think it should be quite easy.... I don't know the result (all untested) but:
    1) try copying this piece of code from the constructor to a method (setInputMask for example) with a parameter, mask:

    Code:
    this.rawMask = mask;
        this.viewMask = '';
        this.maskArray = [];
        var mai = 0;
        var regexp = '';
        for(var i=0; i<mask.length; i++){
            if(regexp){
                if(regexp == 'X'){
                    regexp = '';
                }
                if(mask.charAt(i) == 'X'){
                    this.maskArray[mai] = regexp;
                    mai++;
                    regexp = '';
                } else {
                    regexp += mask.charAt(i);
                }
            } else if(mask.charAt(i) == 'X'){
                regexp += 'X';
                this.viewMask += '_';
            } else if(mask.charAt(i) == '9' || mask.charAt(i) == 'L' || mask.charAt(i) == 'l' || mask.charAt(i) == 'A') {
                this.viewMask += '_';
                this.maskArray[mai] = mask.charAt(i);
                mai++;
            } else {
                this.viewMask += mask.charAt(i);
                this.maskArray[mai] = RegExp.escape(mask.charAt(i));
                mai++;
            }
        }
    
        this.specialChars = this.viewMask.replace(/(L|l|9|A|_|X)/g,'');
    2) in the constructor replace the code with a call to the setInputMask method
    3) when you have to change the mask call the setInputMask method

    I don't hnow what happen if the element has focus when you change the mask (if this can happen in your case and it doesn't work report here what happens)

    Ciao

  4. #104
    Ext User
    Join Date
    Jul 2009
    Posts
    11
    Vote Rating
    0
    Lmouse is on a distinguished road

      0  

    Default


    I am going to test right now!
    Thank you guy!

  5. #105
    Sencha User
    Join Date
    Oct 2008
    Posts
    3
    Vote Rating
    0
    dfm_77 is on a distinguished road

      0  

    Default


    anyone publish the code and sample for download with last version, thanks. and how to install it.

  6. #106
    Ext User
    Join Date
    Jun 2010
    Posts
    1
    Vote Rating
    0
    mario.fts is on a distinguished road

      0  

    Default Bug on form load

    Bug on form load


    When you load a form with data without the mask, the field mask breaks.

    for example:

    mask: 999.999.999-99

    when the data come from server with the mask (306.928.258-00, for example) the mask works great. But when the data come without the mask (for ex: 30692825800) the mask breaks when you try to edit.

    I am attaching some images to show what's going on.

    as you can see, where there should be a dot,-after the 6- there is the field content -caracter 9 -.

    I think that's because of the load does not fire any event to apply the mask.

    Can anyone tell me where can I start to fix this behaviour? what events are fired when the form loads content on the field?

    Regards

    PS: sorry for my bad english.
    Attached Images

  7. #107
    Ext User dandfra's Avatar
    Join Date
    Jun 2007
    Location
    Trento, Italy
    Posts
    122
    Vote Rating
    0
    dandfra is on a distinguished road

      0  

    Default @mario.fts

    @mario.fts


    Sorry for the long wait, I was on holiday.
    When you load a form the setValue of the field is called. The plugin doesn't override this method, since it only manages user input. To gix your problem you have to override the setValue method of your filed to add the formatting before calling the setValue method of the parent class.
    NB: all this is highly speculative and untested

  8. #108
    Ext User
    Join Date
    Jun 2010
    Posts
    1
    Vote Rating
    0
    trase is on a distinguished road

      0  

    Default InputTextMask width renderer

    InputTextMask width renderer


    Hello.

    I have this problem with InputTextMask.

    I have this code:

    {header: 'Value:', sortable: false, dataIndex: 'value', width: 60,renderer: rendererValue,
    editor: new fm.TextField({
    allowBlank: true,
    plugins: [new Ext.ux.InputTextMask({
    mask:'99/99'
    })]
    })
    },

    When I write in the cell and press ENTER the value disappear , but in the store the value has change correctly.
    For more information, in renderer function 'rendererValue' I do this. this function only change the colour of the cell.

    var rendererValue = function (data, cellmd, record, rowIndex,colIndex, store) {

    if (record.data.code != 'N'){
    cellmd.css = 'editCell';
    }
    }

    Anybody can help me?
    Sorry for my English.
    thanks.

  9. #109
    Ext JS Premium Member htammen's Avatar
    Join Date
    Jul 2010
    Location
    Germany, Hannover
    Posts
    74
    Vote Rating
    0
    htammen is on a distinguished road

      0  

    Default


    Quote Originally Posted by dandfra View Post
    Is the following one the wanted behaviour?
    Suppose I have a mask to enter an phone number
    Now my phone number can be 0123/123456 or 01/12345678
    So you write this mask (or something like this):
    99X[0-9]*X/999999X[0-9]*X

    In the field you initially see:
    __/______

    Now, if you want to enter 0123/123456, you type the 0 and 1 and you have:
    01/______

    Now, if you type 2 the mask become
    012/______
    Now, if you type 3 the mask become
    0123/______
    Now, if you type 0 the mask become
    01230/______

    To move after the "/" you have to move using the arrows key, or you have to type /
    Correct?

    The feature is not implemented, but I don't think it's too difficult to do (look at the injectValue method, and getValidatedKey method... ). I don't have time in this moment, but maybe I will look into this (I have the problem of phone numbers too, but not now...) If you need it now, I accept a patch .
    PS: before doing something i will wait for feedback on the wanted behaviour.....
    this does not work for me. I´m using the version from 2008-02-26. Is there a newer one? I haven't found.
    Regular expressions work for single characters but not for repeating values. Means: X[0-9]X works buts X[0-9]*X or X[0-9]{3} don't not work. In the latter cases only one digit is accepted.

    Regards Helmut

  10. #110
    Sencha User
    Join Date
    Aug 2011
    Posts
    1
    Vote Rating
    0
    logicspeak is on a distinguished road

      0  

    Default Zip Code Mask

    Zip Code Mask


    Thanks so much for writing this! It will be incredibly useful to us. Quick question though...how do I create a mask that will accept either a 5 or a 5-4 digit zip code format?

    As in:
    30019 or 30019-1708? Our application has to accept both (or either) as valid formats and I can't figure out how to use the custom regex mask to make it work (if it is even possible).

    Thanks!
    Jason

    Quote Originally Posted by bobbicat71 View Post
    Hi all,
    here is a plugin for textfield that adds a mask input to the field.

    This is the latest version:
    Code:
    // $Id: InputTextMask.js 293638 2008-02-04 14:33:36Z UE014015 $
    
    Ext.namespace('Ext.ux.netbox');
    
    /**
     * InputTextMask script used for mask/regexp operations.
     * Mask Individual Character Usage:
     * 9 - designates only numeric values
     * L - designates only uppercase letter values
     * l - designates only lowercase letter values
     * A - designates only alphanumeric values
     * X - denotes that a custom client script regular expression is specified</li>
     * All other characters are assumed to be "special" characters used to mask the input component.
     * Example 1:
     * (999)999-9999 only numeric values can be entered where the the character
     * position value is 9. Parenthesis and dash are non-editable/mask characters.
     * Example 2:
     * 99L-ll-X[^A-C]X only numeric values for the first two characters,
     * uppercase values for the third character, lowercase letters for the
     * fifth/sixth characters, and the last character X[^A-C]X together counts
     * as the eighth character regular expression that would allow all characters
     * but "A", "B", and "C". Dashes outside the regular expression are non-editable/mask characters.
     * @constructor
     * @param (String) mask The InputTextMask
     * @param (boolean) clearWhenInvalid True to clear the mask when the field blurs and the text is invalid. Optional, default is true.
     */
    Ext.ux.netbox.InputTextMask = function(mask,clearWhenInvalid) {
    
        if(clearWhenInvalid === undefined)
            this.clearWhenInvalid = true;
        else
            this.clearWhenInvalid = clearWhenInvalid;
        this.rawMask = mask;
        this.viewMask = '';
        this.maskArray = new Array();
        var mai = 0;
        var regexp = '';
        for(var i=0; i<mask.length; i++){
            if(regexp){
                if(regexp == 'X'){
                    regexp = '';
                }
                if(mask.charAt(i) == 'X'){
                    this.maskArray[mai] = regexp;
                    mai++;
                    regexp = '';
                } else {
                    regexp += mask.charAt(i);
                }
            } else if(mask.charAt(i) == 'X'){
                regexp += 'X';
                this.viewMask += '_';
            } else if(mask.charAt(i) == '9' || mask.charAt(i) == 'L' || mask.charAt(i) == 'l' || mask.charAt(i) == 'A') {
                this.viewMask += '_';
                this.maskArray[mai] = mask.charAt(i);
                mai++;
            } else {
                this.viewMask += mask.charAt(i);
                this.maskArray[mai] = RegExp.escape(mask.charAt(i));
                mai++;
            }
        }
    
        this.specialChars = this.viewMask.replace(/(L|l|9|A|_|X)/g,'');
    };
    
    Ext.ux.netbox.InputTextMask.prototype = {
    
        init : function(field) {
            this.field = field;
    
            if (field.rendered){
                this.assignEl();
            } else {
                field.on('render', this.assignEl, this);
            }
    
            field.on('blur',this.removeValueWhenInvalid, this);
            field.on('focus',this.processMaskFocus, this);
        },
    
        assignEl : function() {
            this.inputTextElement = this.field.getEl().dom;
            this.field.getEl().on('keypress', this.processKeyPress, this);
            this.field.getEl().on('keydown', this.processKeyDown, this);
            if(Ext.isSafari || Ext.isIE){
                this.field.getEl().on('paste',this.startTask,this);
                this.field.getEl().on('cut',this.startTask,this);
            }
            if(Ext.isGecko || Ext.isOpera){
                this.field.getEl().on('mousedown',this.setPreviousValue,this);
            }
            if(Ext.isGecko){
              this.field.getEl().on('input',this.onInput,this);
            }
            if(Ext.isOpera){
              this.field.getEl().on('input',this.onInputOpera,this);
            }
        },
        onInput : function(){
            this.startTask(false);
        },
        onInputOpera : function(){
          if(!this.prevValueOpera){
            this.startTask(false);
          }else{
            this.manageBackspaceAndDeleteOpera();
          }
        },
        
        manageBackspaceAndDeleteOpera: function(){
          this.inputTextElement.value=this.prevValueOpera.cursorPos.previousValue;
          this.manageTheText(this.prevValueOpera.keycode,this.prevValueOpera.cursorPos);
          this.prevValueOpera=null;
        },
    
        setPreviousValue : function(event){
            this.oldCursorPos=this.getCursorPosition();
        },
    
        getValidatedKey : function(keycode, cursorPosition) {
            var maskKey = this.maskArray[cursorPosition.start];
            if(maskKey == '9'){
                return keycode.pressedKey.match(/[0-9]/);
            } else if(maskKey == 'L'){
                return (keycode.pressedKey.match(/[A-Za-z]/))? keycode.pressedKey.toUpperCase(): null;
            } else if(maskKey == 'l'){
                return (keycode.pressedKey.match(/[A-Za-z]/))? keycode.pressedKey.toLowerCase(): null;
            } else if(maskKey == 'A'){
                return keycode.pressedKey.match(/[A-Za-z0-9]/);
            } else if(maskKey){
                return (keycode.pressedKey.match(new RegExp(maskKey)));
            }
            return(null);
        },
    
        removeValueWhenInvalid : function() {
            if(this.clearWhenInvalid && this.inputTextElement.value.indexOf('_') > -1){
                this.inputTextElement.value = '';
            }
        },
    
        managePaste : function() {
            if(this.oldCursorPos==null){
              return;
            }
            var valuePasted=this.inputTextElement.value.substring(this.oldCursorPos.start,this.inputTextElement.value.length-(this.oldCursorPos.previousValue.length-this.oldCursorPos.end));
            if(this.oldCursorPos.start<this.oldCursorPos.end){//there is selection...
              this.oldCursorPos.previousValue=
                this.oldCursorPos.previousValue.substring(0,this.oldCursorPos.start)+
                this.viewMask.substring(this.oldCursorPos.start,this.oldCursorPos.end)+
                this.oldCursorPos.previousValue.substring(this.oldCursorPos.end,this.oldCursorPos.previousValue.length);
              valuePasted=valuePasted.substr(0,this.oldCursorPos.end-this.oldCursorPos.start);
            }
            this.inputTextElement.value=this.oldCursorPos.previousValue;
            keycode={unicode :'',
            isShiftPressed: false,
            isTab: false,
            isBackspace: false,
            isLeftOrRightArrow: false,
            isDelete: false,
            pressedKey : ''
            }
            var charOk=false;
            for(var i=0;i<valuePasted.length;i++){
                keycode.pressedKey=valuePasted.substr(i,1);
                keycode.unicode=valuePasted.charCodeAt(i);
                this.oldCursorPos=this.skipMaskCharacters(keycode,this.oldCursorPos);
                if(this.oldCursorPos===false){
                    break;
                }
                if(this.injectValue(keycode,this.oldCursorPos)){
                    charOk=true;
                    this.moveCursorToPosition(keycode, this.oldCursorPos);
                    this.oldCursorPos.previousValue=this.inputTextElement.value;
                    this.oldCursorPos.start=this.oldCursorPos.start+1;
                }
            }
            if(!charOk && this.oldCursorPos!==false){
                this.moveCursorToPosition(null, this.oldCursorPos);
            }
            this.oldCursorPos=null;
        },
    
        processKeyDown : function(e){
            this.processMaskFormatting(e,'keydown');
        },
    
        processKeyPress : function(e){
            this.processMaskFormatting(e,'keypress');
        },
    
        startTask : function(setOldCursor){
            if(this.task==undefined){
                this.task=new Ext.util.DelayedTask(this.managePaste,this);
          }
            if(setOldCursor!== false){
                this.oldCursorPos=this.getCursorPosition();
          }
          this.task.delay(0);
        },
    
        skipMaskCharacters : function(keycode, cursorPos){
            if(cursorPos.start!=cursorPos.end && (keycode.isDelete || keycode.isBackspace))
                return(cursorPos);
            while(this.specialChars.match(RegExp.escape(this.viewMask.charAt(((keycode.isBackspace)? cursorPos.start-1: cursorPos.start))))){
                if(keycode.isBackspace) {
                    cursorPos.dec();
                } else {
                    cursorPos.inc();
                }
                if(cursorPos.start >= cursorPos.previousValue.length || cursorPos.start < 0){
                    return false;
                }
            }
            return(cursorPos);
        },
    
        isManagedByKeyDown : function(keycode){
            if(keycode.isDelete || keycode.isBackspace){
                return(true);
            }
            return(false);
        },
    
        processMaskFormatting : function(e, type) {
            this.oldCursorPos=null;
            var cursorPos = this.getCursorPosition();
            var keycode = this.getKeyCode(e, type);
            if(keycode.unicode==0){//?? sometimes on Safari
                return;
            }
            if((keycode.unicode==67 || keycode.unicode==99) && e.ctrlKey){//Ctrl+c, let's the browser manage it!
                return;
            }
            if((keycode.unicode==88 || keycode.unicode==120) && e.ctrlKey){//Ctrl+x, manage paste
                this.startTask();
                return;
            }
            if((keycode.unicode==86 || keycode.unicode==118) && e.ctrlKey){//Ctrl+v, manage paste....
                this.startTask();
                return;
            }
            if((keycode.isBackspace || keycode.isDelete) && Ext.isOpera){
              this.prevValueOpera={cursorPos: cursorPos, keycode: keycode};
              return;
            }
            if(type=='keydown' && !this.isManagedByKeyDown(keycode)){
                return true;
            }
            if(type=='keypress' && this.isManagedByKeyDown(keycode)){
                return true;
            }
            if(this.handleEventBubble(e, keycode, type)){
                return true;
            }
            return(this.manageTheText(keycode, cursorPos));
        },
        
        manageTheText: function(keycode, cursorPos){
          if(this.inputTextElement.value.length === 0){
              this.inputTextElement.value = this.viewMask;
          }
          cursorPos=this.skipMaskCharacters(keycode, cursorPos);
          if(cursorPos===false){
              return false;
          }
          if(this.injectValue(keycode, cursorPos)){
              this.moveCursorToPosition(keycode, cursorPos);
          }
          return(false);
        },
    
        processMaskFocus : function(){
            if(this.inputTextElement.value.length == 0){
                var cursorPos = this.getCursorPosition();
                this.inputTextElement.value = this.viewMask;
                this.moveCursorToPosition(null, cursorPos);
            }
        },
    
        isManagedByBrowser : function(keyEvent, keycode, type){
            if(((type=='keypress' && keyEvent.charCode===0) ||
                type=='keydown') && (keycode.unicode==Ext.EventObject.TAB ||
                keycode.unicode==Ext.EventObject.RETURN ||
                keycode.unicode==Ext.EventObject.ENTER ||
                keycode.unicode==Ext.EventObject.SHIFT ||
                keycode.unicode==Ext.EventObject.CONTROL ||
                keycode.unicode==Ext.EventObject.ESC ||
                keycode.unicode==Ext.EventObject.PAGEUP ||
                keycode.unicode==Ext.EventObject.PAGEDOWN ||
                keycode.unicode==Ext.EventObject.END ||
                keycode.unicode==Ext.EventObject.HOME ||
                keycode.unicode==Ext.EventObject.LEFT ||
                keycode.unicode==Ext.EventObject.UP ||
                keycode.unicode==Ext.EventObject.RIGHT ||
                keycode.unicode==Ext.EventObject.DOWN)){
                    return(true);
            }
            return(false);
        },
    
        handleEventBubble : function(keyEvent, keycode, type) {
            try {
                if(keycode && this.isManagedByBrowser(keyEvent, keycode, type)){
                    return true;
                }
                keyEvent.stopEvent();
                return false;
            } catch(e) {
                alert(e.message);
            }
        },
    
        getCursorPosition : function() {
            var s, e, r;
            if(this.inputTextElement.createTextRange){
                r = document.selection.createRange().duplicate();
                r.moveEnd('character', this.inputTextElement.value.length);
                if(r.text === ''){
                    s = this.inputTextElement.value.length;
                } else {
                    s = this.inputTextElement.value.lastIndexOf(r.text);
                }
                r = document.selection.createRange().duplicate();
                r.moveStart('character', -this.inputTextElement.value.length);
                e = r.text.length;
            } else {
                s = this.inputTextElement.selectionStart;
                e = this.inputTextElement.selectionEnd;
            }
            return this.CursorPosition(s, e, r, this.inputTextElement.value);
        },
    
        moveCursorToPosition : function(keycode, cursorPosition) {
            var p = (!keycode || (keycode && keycode.isBackspace ))? cursorPosition.start: cursorPosition.start + 1;
            if(this.inputTextElement.createTextRange){
                cursorPosition.range.move('character', p);
                cursorPosition.range.select();
            } else {
                this.inputTextElement.selectionStart = p;
                this.inputTextElement.selectionEnd = p;
            }
        },
    
        injectValue : function(keycode, cursorPosition) {
            if (!keycode.isDelete && keycode.unicode == cursorPosition.previousValue.charCodeAt(cursorPosition.start))
                return true;
            var key;
            if(!keycode.isDelete && !keycode.isBackspace){
                key=this.getValidatedKey(keycode, cursorPosition);
            } else {
                if(cursorPosition.start == cursorPosition.end){
                    key='_';
                    if(keycode.isBackspace){
                        cursorPosition.dec();
                    }
                } else {
                    key=this.viewMask.substring(cursorPosition.start,cursorPosition.end);
                }
            }
            if(key){
                this.inputTextElement.value = cursorPosition.previousValue.substring(0,cursorPosition.start)
                    + key +
                    cursorPosition.previousValue.substring(cursorPosition.start + key.length,cursorPosition.previousValue.length);
                return true;
            }
            return false;
        },
    
        getKeyCode : function(onKeyDownEvent, type) {
            var keycode = {};
            keycode.unicode = onKeyDownEvent.getKey();
            keycode.isShiftPressed = onKeyDownEvent.shiftKey;
            
            keycode.isDelete = ((onKeyDownEvent.getKey() == Ext.EventObject.DELETE && type=='keydown') || ( type=='keypress' && onKeyDownEvent.charCode===0 && onKeyDownEvent.keyCode == Ext.EventObject.DELETE))? true: false;
            keycode.isTab = (onKeyDownEvent.getKey() == Ext.EventObject.TAB)? true: false;
            keycode.isBackspace = (onKeyDownEvent.getKey() == Ext.EventObject.BACKSPACE)? true: false;
            keycode.isLeftOrRightArrow = (onKeyDownEvent.getKey() == Ext.EventObject.LEFT || onKeyDownEvent.getKey() == Ext.EventObject.RIGHT)? true: false;
            keycode.pressedKey = String.fromCharCode(keycode.unicode);
            return(keycode);
        },
    
        CursorPosition : function(start, end, range, previousValue) {
            var cursorPosition = {};
            cursorPosition.start = isNaN(start)? 0: start;
            cursorPosition.end = isNaN(end)? 0: end;
            cursorPosition.range = range;
            cursorPosition.previousValue = previousValue;
            cursorPosition.inc = function(){cursorPosition.start++;cursorPosition.end++;};
            cursorPosition.dec = function(){cursorPosition.start--;cursorPosition.end--;};
            return(cursorPosition);
        }
    };
    
    Ext.applyIf(RegExp, {
      escape : function(str) {
        return new String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
      }
    });
    
    Ext.ux.InputTextMask=Ext.ux.netbox.InputTextMask;
    And here is an example of the usage:
    Code:
    var dateTimeField = new Ext.form.TextField({plugins: [new Ext.ux.InputTextMask('99/99/9999 99:99', true)]});
    Enjoy!

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi