s.k.Soni
s.k.Soni

Reputation: 1310

TypeError: $(...).mask is not a function in date format using jquery

When I am doing the date format to the input text using jQuery, it shows this type of error.

Here is my code

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="text" id="date" name="bday"/>

    $(document).ready(function () {
        alert();
        $("#date").mask("99/99/9999", { placeholder: "mm/dd/yyyy" });
    });

Upvotes: 0

Views: 4382

Answers (1)

The_Outsider
The_Outsider

Reputation: 1925

Swapping the scripts by putting in jquery first and then the mask works, as has been posted in the comments. Check the snippet.

$(document).ready(function () {
        alert();
        $("#date").mask("99/99/9999", { placeholder: "mm/dd/yyyy" });
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.10/jquery.mask.js"></script>


<input type="text" id="date" name="bday"/>

    

Upvotes: 2

Related Questions