views:

85

answers:

1

Trying to use Josh Bush's masked input plugin.

I want to shift focus and do other things once the person puts their cell phone in. I mask to a phone shape. When I hit the last letter, I want it to trigger a javascript function. Right now that function just alerts hi.

I even copied the demo right off Josh Bush's page: http://digitalbush.com/projects/masked-input-plugin/ the third one for triggering something to complete. Copying it verbatim and it still doesn't work?

Am I crazy? Can anyone get this to work.

function jump(){
    alert('hi');
}

$(document).ready(function(){
    $("#cellphone").focus();
    jQuery(function($){
        $("#product").mask("(999) 999-9999",{completed:function(){jump();}});      
    });
 });     
A: 

hi karl,

I just tried this plugin and it works great, at it seems that the complete function is somewhat broken, I'm using the latest 1.2.2. If you download the uncompressed and replaced line 169

changed this on line 169:

if (settings.completed && next == len)

to

if (settings.completed && next == len+1)

also you're targeting the wrong id

$(document).ready(function(){
    $("#cellphone").focus();
    jQuery(function($){
        $("#product").mask("(999) 999-9999",{completed:function(){jump();}});      
    });
 }); 

first you're checking #cellphone right? then #product should suppose be #cellphone,

please allow me to edit your code a bit:

$(document).ready(function(){
    function jump(){
    alert('hi');
    }                                                    
    $("#cellphone").focus();
    $("#cellphone").mask("(999) 999-9999",{completed:function(){jump();}});      
}); 
mastah