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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...