jQuery - MaskedInput

<< Click to Display Table of Contents >>

Navigation:  jQuery >

jQuery - MaskedInput

Previous pageReturn to chapter overviewNext page

VEJA iMAX

 

Default.aspx

 

<head runat="server">

  <title></title>

  <script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>

  <script language="javascript" type="text/javascript" src="util/jquery.maskedinput-1.3.min.js"></script>

  <script type="text/javascript">

       jQuery(function ($) {

           $(".mask_data").mask("99/99/9999");

           $(".mask_fone").mask("(99) 9999-9999");

           $(".mask_cep").mask("999.99-999");

           $(".mask_placa").mask("AAA-9999");

       });

  </script>

</head>

<body>

  <form id="form1" runat="server">

  <asp:Label ID="lblFone" runat="server">Fone:</asp:Label>

  <br />

  <asp:TextBox ID="txtFone" class="mask_fone" runat="server"></asp:TextBox>

  <br />

  <br />

  <asp:Label ID="lblData" runat="server">Data:</asp:Label>

  <br />

  <asp:TextBox ID="txtData" class="mask_data" runat="server"></asp:TextBox>

  <br />

  <br />

  <asp:Label ID="lblCEP" runat="server">CEP:</asp:Label>

  <br />

  <asp:TextBox ID="txtCEP" class="mask_cep" runat="server"></asp:TextBox>

  <br />

  <br />

  <asp:Label ID="lblPlaca" runat="server">Placa:</asp:Label>

  <br />

  <asp:TextBox ID="txtPlaca" class="mask_placa" runat="server"></asp:TextBox>

  </form>

</body>

 

Extras

 

Se não quiser o "_" na máscara:

 

$("#product").mask("99/99/9999",{placeholder:" "});

 

 

MaskedInput

 

Aqui tem o fonte do MaskedInput:

 

min

uncompressed

 

Mas sugiro baixar a última versão em

http://digitalbush.com/projects/masked-input-plugin/