Jump to content

Recommended Posts

Posted

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
Posted

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  :)

  • 4 years later...
  • 5 months later...
Posted
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

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...