Jquery mask in a form

Asked

Viewed 318 times

1

is a relatively simple doubt 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 the top I need a mask in the CPF for example. Thank you all

1 answer

1

There is a Jquery plugin called Jquery Mask

just add the Jquery Mask library and insert the script

$('.seu_input'). Mask('000.000.000-00', {Reverse: true});

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

$('.seu_input'). Mask('000.000.000-00');

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

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.