Menu

how to remove mask from field

2009-10-07
2013-04-22
  • Ben Erridge

    Ben Erridge - 2009-10-07

    I am using icefaces and the input mask sometimes the script that creates an input mask runs twice. I want to remove any previous input masks on a given element.
    what is the best way to accomplish this?
    Thanks

     
  • Ben Erridge

    Ben Erridge - 2009-10-13

    I have been successfull removing eventlisteners from firefox and chrome but ie I still can't get to work correctly.
    I added a new function to JavaScriptUtils.js

        function removeObserver(object,eventName,handler){
            object=getObject(object);
            if(object!=null){
                if(object.removeEventListener){
                    object.removeEventListener(eventName,handler,false);
                } else if(object.detachEvent){
                    object.detachEvent("on"+eventName,function(){
                        return invokeAsMethod(object,handler,)
                    })
                } else {
                    object=null;
                }
            }
        }

    as well as adding function to InputMask.js

        this.disable=function(){
                removeObserver(this.control,"blur",onBlur);
                removeObserver(this.control,"focus",onFocus);
                removeObserver(this.control,"keyup",onKeyUp);
                removeObserver(this.control,"keypress",onKeyPress);
                removeObserver(this.control,"keydown",onKeyDown); 
            }

    No luck with IE though any help would be greatly appreciated!

     
  • Lluis Martinez

    Lluis Martinez - 2009-10-13

    It's possible that event names in IE are case-sensitive. Therefore onblur <> onBlur. Check this out.

    Another option is to look at the YUI library, it has a good support of event listeners, perhaps you can copy some code snippet from there.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.