Search code examples
javascriptjquerymasking

Jquery script doesnt work


I'm newbie with jQuery and I my facing the following problem.

I'm trying to use a mask, but the script doesn't work. At all.

The code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="js/jquery.maskedinput.js" type="text/javascript"></script> 

    <script>

        $( document ).ready(function() {
            $("#date").mask("99/99/9999",{placeholder:"mm/dd/yyyy"});
            $("#phone").mask("(999) 999-9999");
            $("#tin").mask("99-9999999");
            $("#ssn").mask("999-99-9999");
        });


    </script>

</head>
<body>
    <input type="text" id="date">
    <input type="text" id="phone">
    <input type="text" id="tin">
    <input type="text" id="ssn">

</body>
</html>

What's wrong?

I'm using the plugin from this site: http://digitalbush.com/projects/masked-input-plugin/


Solution

  • I checked the code. And I used this latest jQuery Mask Plugin. It works. Here are some examples , they might help.

    Only change I did is

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

    You may have put your files in wrong location. You can check those using the built in inspect element functionality (right click and you can see it) in Google chrome. If the console indicate missing .js files you can correct them. There are ways for other browser to check those also.