Posted By

millano572 on 09/23/13


Tagged

jquery mask maskedinput


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

millano572


Masked Input


 / Published in: JavaScript
 

uso do masked input

  1. <script src="js/jquery-1.8.2.js" type="text/javascript"></script>
  2.  
  3. <script src="js/maskedinput-1.3.min.js" type="text/javascript"></script>
  4.  
  5. <script type="text/javascript">
  6. //$(document).ready(function () {
  7. function pageLoad() {
  8. $('.telefone').mask('(99)9999-9999');
  9. $('.celular').focusout(function () {
  10. var phone, element;
  11. element = $(this);
  12. element.unmask();
  13. phone = element.val().replace(/\D/g, '');
  14. if (phone.length > 10) {
  15. element.mask("(99)99999-9999");
  16. } else {
  17. element.mask("(99)9999-9999?9");
  18. }
  19. }).trigger('focusout');
  20. }
  21.  
  22. </script>

Report this snippet  

You need to login to post a comment.