Creating masks with javascript

1

I need to create masks for a inputs that I have in the code, and I had already asked about it, but I think the post was outdated and then "forgotten". However what I had gotten with that post was:

HTML:

Within <HEAD> :

        <script src="assets/plugins/jquery.maskedinput.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>

Within<BODY>:

<inputtype="text" name="search" id="search" placeholder="Escreva o número de processo aqui..." required maxlength="5">

Javascript after </HTML> :

<script type="text/javascript">

        $(document).ready(function(){
            $("#search").mask("99999");
        });

and it still does not work. I already tried to create a new page to test this function but it also did not work. Anyone have any idea what's going on?

    
asked by anonymous 24.03.2016 / 03:01

2 answers

2

The problem occurs because of the failure to load the scripts. Make the following change:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script><scriptsrc="assets/plugins/jquery.maskedinput.js"></script>

Edit: I mounted a fiddle: link and apparently it worked.

    
24.03.2016 / 03:14
1

I did it! I changed

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script><scriptsrc="assets/plugins/jquery.maskedinput.js"></script>

for

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>

Thanks for the help

    
24.03.2016 / 04:20