Advertisement
kavallo

Mascara HTML

Nov 10th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. $(".cpf").mask("999.999.999-99");
  4. $('.cpf').blur(function () {
  5. var id=$(this).attr("id");
  6. var val=$(this).val();
  7. var pattern = new RegExp(/[0-9]{3}[\.]?[0-9]{3}[\.]?[0-9]{3}[-]?[0-9]{2}/);
  8.  
  9. if(val.match(pattern) == null){
  10. $("#"+id+"_error").html("Digite um CPF válido");
  11. }
  12. /* addition: for clearing if valid */
  13. else {
  14. $("#"+id+"_error").html("");
  15. }
  16. /* end addition */
  17. });
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement