Jquery Plugin Mask does not work

Asked

Viewed 52 times

0

I would like to add a mask for landline registration on a system screen. But Jquery is not working. Follow code below.

<script>
    $(document).ready(function(){
        $('#tel').mask('(00)0000-0000');
    });

I added this in footer.php and the library call is in header.php. I’ve tried to put both (call and script) in the form itself but also no effect.

  • Error appears on console?

  • That one #tel is an input text?

  • No error appears on console, @Sam

  • Yes, it is the id of an input text

1 answer

0

Good afternoon.

Check if the jQuery call is before the jQueryMask library call.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.js"></script>

Also check if you are closing the script tag at the end

<script>
$(document).ready(function(){
    $('#tel').mask('(00)0000-0000');
});
</script>

And also remembering that the script should come after the library calls.

If that doesn’t help, post more code snippets to verify.

Browser other questions tagged

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