Jump to content

Mascara Multipla Cpf / Cnpj


Cristian

Recommended Posts

Pessoal, estou precisando de ajuda de alguem que entenda de javascript

O codigo abaixo deve ter algum erro de sintaxe.. Quando eu utilizo somente mascara pro telefone (customfield1) funciona, quando coloco junto a do CPF/CNPJ (customfield2) não funciona mais nenhuma.


<script>

		 jQuery(function($) {

		 $.mask.definitions['~']='[+-]';

		 $("#postcode").mask("99999-999");

   $("#phonenumber").mask("(99)9999-9999");

		 $("#customfield2").focusout(function(){

				  var doc, element2;

				  element2 = $(this);

				  element2.unmask();

				  phone = element2.val().replace(/\D/g, '');

				  if(doc.length > 9) {

						  element2.mask("999.999.999.99???");

				  } else {

						  element2.mask("99.999.999/9999-99");

				  }

			    }).trigger('focusout');

		 });

   $("#customfield2").focusout(function(){

				  var phone, element;

				  element = $(this);

				  element.unmask();

				  phone = element.val().replace(/\D/g, '');

				  if(phone.length > 10) {

						  element.mask("(99)99999-999?9");

				  } else {

						  element.mask("(99)9999-9999?9");

				  }

			    }).trigger('focusout');

		 });

		 </script>

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Do you agree with our terms?