0

I couldn't for some reason get the jquery input mask plugin to work. I didn't know jquery so any person whom had worked in jquery please reply. here is my testPage.php code

<html>
    <head>
        <script src="view/script/jquery-2.1.1.js" type="text/javascript"></script>
        <script src="view/script/jquery.inputmask.js" type="text/javascript"></script>
    </head>
    <body>
        <script type="text/javascript">
            jQuery(function ($) {
                $("#cnicFieldName").mask("99999-9999999-9");
            });
        </script>
        ID :<input type="text" id="cnicFieldName" /> <br />
    </body>
</html>

FYI: Yes I had included both the jquery (latest avalible version) and jquery.inputmask.js from the dist folder i.e. jquery.inputmask-3.x\dist\inputmask\jquery.inputmask.js. (I had downloaded both from jquery.com (both the main jquery file and the input mask plugin)

When I select the input nothing appears in it i.e. underscores etc and it didn't prevent charecter data in it. I am sure I am missing a very minute detail but I couldn't figure out what that is. Thanking you in advance for considering to reply.

1 Answers1

1

You need to call mask after the document is ready. And you are using mask("99999-9999999-9") inlace of inputmask("99999-9999999-9");.

<body>
    <script type="text/javascript">
        $(document).ready(function(){ 
            $("#cnicFieldName").inputmask("99999-9999999-9");
        });
    </script>
    ID :<input type="text" id="cnicFieldName" /> <br />
</body>

You can refer jquery.inputmask 3.x plugin or check JSFiddle

DimoMohit
  • 735
  • 4
  • 17