JQuery Mask working only for one field

2

Dear, in my code I need to insert two mask , but only INSC_EST is working, the other is not. Here is the code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript" src="../../js/jquery-1.7.min.js" ></script>
<script type="text/javascript" src="../../js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../js/jquery-ui.js"></script>
<script type="text/javascript" src="../../js/jquery.maskedinput.js"></script>

    $(function() {$( "#datepicker" ).datepicker();});  
    $(function() {$( "#tabs" ).tabs();});
    $(document).ready(function(){
       $("input.INSC_EST").mask("999.999.999-9999");
       $("input.CGC").mask("99.999.999/9999-99");
    });

   <fieldset id="Fiscal" class="Fiscal">
     <legend><b>Fiscal:</b></legend>
       <label for="Natureza">
            Natureza:   
         <select name="NATUREZA">
           <option value="1">Pessoa Fisica</option>
           <option value="2" selected>Pessoa Juridica</option>
           <option value="3">Trading</option>
         </select>
       </label>
       <label for="CGC">
         CGC:<input type="text" class="CGC" name="CGC" id="CGC" value="" />
       </label>
       <label for="INSC_MUNIC">
         Insc. Municipal:<input class="class5" type="text" name="INSC_MUNIC" MAXLENGTH="11" value=""/>
       </label>
         <label for="INSC_EST">
         Insc. Estadual:    <input class="INSC_EST" type="text" name="INSC_EST" value=""/>
       </label>
         <label for="ST">
           ST: <select>
           <option value="1" selected>SIM</option>
           <option value="2">NAO</option>
           </select>
         </label>

  </fieldset>
</div>

    
asked by anonymous 05.09.2014 / 13:28

1 answer

1

Your code works, the proof is here:

link

What I noticed was that the masks only apply when you report all the numbers, which is probably not what you want.

Note that I made a small change here:

$("input.INSC_EST").mask("999.999.999-9999");
$("input.CGC").mask("99.999.999/9999-99");

Add the reverse parameter for the component to format the field as you enter the values, as follows:

$("input.INSC_EST").mask("999.999.999-9999", {reverse: true});
$("input.CGC").mask("99.999.999/9999-99", {reverse: true});

EDIT

This component is very well documented, it follows a show case with several examples:

link

    
05.09.2014 / 13:52