Jump to content

Phone mask input with 9 digit


lagtto

Recommended Posts

Hi, This is a phone mask input with 9 digit for the jQuery.

 

 

UniEdit1 -> ClientEvents -> ExtEvents -> add afterrender function:

 

function OnAfterrender(sender)
{
  $("#"+sender.id+"-inputEl")  
    .mask("(99) 99999-999?9")  
    .live('focusout', function (event) {  
      var target, phone, element;  
        target = (event.currentTarget) ? event.currentTarget : event.srcElement;  
        phone = target.value.replace(/\D/g, '');  
        element = $(target);  
        element.unmask();  
        if(phone.length > 10) {  
          element.mask("(99) 99999-999?9");  
        } else {  
          element.mask("(99) 9999-9999?9");  
        }  
    }); 
}

 

 

Best regards.

  • Upvote 1
Link to comment
Share on other sites

1. Thank you...

 

2. Next time please make your code look more efficient (use code wrapper) '<>': see result

function OnAfterrender(sender)
{
  $("#"+sender.id+"-inputEl")  
    .mask("(99) 99999-999?9")  
    .live('focusout', function (event) {  
      var target, phone, element;  
        target = (event.currentTarget) ? event.currentTarget : event.srcElement;  
        phone = target.value.replace(/\D/g, '');  
        element = $(target);  
        element.unmask();  
        if(phone.length > 10) {  
          element.mask("(99) 99999-999?9");  
        } else {  
          element.mask("(99) 9999-9999?9");  
        }  
    }); 
} 

3. We all welcome you in our community  :)

Link to comment
Share on other sites

  • 4 years later...
  • 5 months later...
On 11/5/2014 at 6:55 PM, mhmda said:

1. Thank you...

 

2. Next time please make your code look more efficient (use code wrapper) '<>': see result


function OnAfterrender(sender)
{
  $("#"+sender.id+"-inputEl")  
    .mask("(99) 99999-999?9")  
    .live('focusout', function (event) {  
      var target, phone, element;  
        target = (event.currentTarget) ? event.currentTarget : event.srcElement;  
        phone = target.value.replace(/\D/g, '');  
        element = $(target);  
        element.unmask();  
        if(phone.length > 10) {  
          element.mask("(99) 99999-999?9");  
        } else {  
          element.mask("(99) 9999-9999?9");  
        }  
    }); 
} 

3. We all welcome you in our community  :)

I didn't understand how to use it.
I could clarify.

Capturar.JPG

Capturar.JPG

Capturar2.JPG

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...