Error in the email field mask and validation

Asked

Viewed 491 times

0

I am trying to implement a mask and validate the email field using the plugin inputmask unsuccessfully the mask does not appear and consequently does not validate, why ?

That is the code:

 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">   
</asp:Content>

 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src='<%= Page.ResolveUrl("~/jquery-3.3.1.min.js") %>'></script>
<script src='<%= Page.ResolveUrl("~/scripts/inputmask/jquery.inputmask.js") %>'></script>

 <script type="text/javascript">
       (function ($) {
           $(function () {

               $('#txtEmail').inputmask({
                   mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
                   greedy: false,
                   onBeforePaste: function (pastedValue, opts) {
                       pastedValue = pastedValue.toLowerCase();
                       return pastedValue.replace("mailto:", "");
                   },
                   definitions: {
                       '*': {
                           validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
                           casing: "lower"
                       }
                   }
               });
           });
       })(jQuery);

    </script>


    <div class="col-md-8">
        <label for="txtEmail" class="font-weight-bold">Email</label>
        <asp:TextBox ID="txtEmail" runat="server" class="form-control" MaxLength="50" ToolTip="Digite o Email" ClientIDMode="Static"></asp:TextBox>
    </div>
</asp:Content>

Error

Uncaught TypeError: Inputmask is not a constructor
    at w.fn.init.$.fn.inputmask (jquery.inputmask.js:76)
    at HTMLDocument.<anonymous> (CadUsuario.aspx?idusuario=7:259)
    at l (VM792 jquery-3.3.1.min.js:2)
    at c (VM792 jquery-3.3.1.min.js:2)

inserir a descrição da imagem aqui

  • Change the file jquery.inputmask.js for jquery.inputmask.bundle.js

  • And what do you mean by email mask? when the script should know it needs to insert a @ or a .

  • @leandro Angelo insert a @

  • @Jorge. M downloaded jqu3ry.inputmask from Nuget and there is no such file as jquery.input.Bundle.js, the name of this file is correct ?

No answers

Browser other questions tagged

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