JQuery mask in a form

0

is a relatively simple question for you with more experience but I'm not getting a mask in an HTML form.

<div class="site-element" element-id="1515038900431" element-type="skinInputElement">
                    <div>

                        <div class="site-element" element-id="id1427284680880" element-type="skinHierarchyBox">
                            <div class="element-children-container">



                                <div class="site-element" element-id="id1427284680884" element-type="label" >CPF</div>

                                <div class="site-element" element-id="id1427284680883" element-type="TextInputField"><input type="text"></div>
                            </div>
                        </div>
                    </div>
                </div>

In this div I need a mascara in the CPF for example. Thank you all

    
asked by anonymous 11.01.2018 / 01:39

1 answer

0

There is a Jquery plugin called Jquery Mask

Just add the Jquery Mask library and insert the script

$ ('your_input'). mask ('000.000.000-00', {reverse: true});

// if you do not want cpf to be typed in reverse

$ ('your_input'). mask ('000.000.000-00');

Below is an example working, I hope I have helped;)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.mask.min.js"></script>
<div class="site-element" element-id="1515038900431" element-type="skinInputElement">
  <div>
    <div class="site-element" element-id="id1427284680880" element-type="skinHierarchyBox">
      <div class="element-children-container">
        <div class="site-element" element-id="id1427284680884" element-type="label" >CPF</div>
        <div class="site-element" element-id="id1427284680883" element-type="TextInputField">
          <input type="text"></div>
        </div>
      </div>
  </div>
</div>
<script>
  $('.site-element input').mask('000.000.000-00', {reverse: true});
</script>
    
11.01.2018 / 09:04