jQuery Mask plugin for CPF

Asked

Viewed 8,313 times

7

I would like to know what I am doing wrong. I am using this plugin https://github.com/igorescobar/jQuery-Mask-Plugin to try to apply a cpf mask (need to be through CDN) but when I enter the data in the field, nothing happens. Follow my head where I import the CDNS:

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.12/jquery.mask.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.12/jquery.mask.min.js"></script>

Javascript function:

<script>
//Mascara CPF
$(document).ready(function(){
  $('#paramCpf').mask('999.999.999-99');
});
</script>

My field of CPF:

<TR>
    <TD> <b>CPF</b> </TD>
    <TD> <INPUT type="text" name="paramCpf" id="paramCpf" value=""> </TD>
</TR>
  • Are you importing jQuery ? not the mask plugin, the same jQuery, are different things

1 answer

4


Two things, see if you import JQUERY too, these 2 libs that you’ve imported is only for Mask, all jquery plugins ask for Jquery import too.

Second thing, from an F12 (if it’s Chrome) and go to "Network" and see if you really have 200 status items that you imported.
Follow the jquery Cdn for you to test

<script
  src="https://code.jquery.com/jquery-3.2.1.min.js"
  integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  crossorigin="anonymous"></script>
  • That’s right, friend, I started messing with jQuery a little while ago and I had forgotten that detail! Thanks for the quick and objective response!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.