maskedinput Uncaught TypeError: $(...).mask is not a function

37,206

Solution 1

Change this line from

$(document).ready(function(){ 

to

$(document).ready(function($){

Solution 2

I got this same error too, but in my case I forgot to import maskedinput.min.js

<script src="/js/jquery.maskedinput.min.js" type="text/javascript"></script>

And I was searching Google for a solution haha.

Solution 3

I solved my problem, I had to remove duplicate script connections

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.maskedinput-1.3.min.js"></script>
Share:
37,206
Susana Santos
Author by

Susana Santos

Brazilian from Rio de Janeiro. Speaks portuguese(obviously), english, spanish and a little bit of hungarian. PHP Developer, OctoberCMS enthusiast and a great swimmer cause life is more than coding.

Updated on February 27, 2020

Comments

  • Susana Santos
    Susana Santos over 4 years

    Good afternoon On my there is

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript" src="{{ asset('bundles/reflorestasite/js/jquery.maskedinput.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('bundles/reflorestasite/js/validacoes.js') }}"></script>
    <script type="text/javascript" src="{{ asset_url }}"></script>
    

    And on "validacoes.js" file there is

    $(document).ready(function(){
    
      $(".cpf").mask("999.999.999-99");
      $('.cpf').blur(function () {
        var id=$(this).attr("id");
        var val=$(this).val();
        var pattern = new RegExp(/[0-9]{3}[\.]?[0-9]{3}[\.]?[0-9]{3}[-]?[0-9]{2}/);
    
        if(val.match(pattern) == null){
          $("#"+id+"_error").html("Digite um CPF válido");
        }
      });
    });
    

    I've already verifed at console and all javascript files are there. However i'm getting the error "Uncaught TypeError: $(...).mask is not a function"

    Does anyone has a clue why symfony is not recognizing the maskedinput plugin?

    Thankyou very much.