javascriptjqueryjquery-inputmask

Using Inputmask jquery plugin default placeholder text not displayed


I am using the input mask jQuery plugin but I am unable to see placeholder text by default but on hover it will be displayed.

$("input[name='birth_year_1']").inputmask("dd/mm/yyyy", {
  placeholder: "dd/mm/yyyy"
});

Solution

  • Set the clearMaskOnLostFocus option

    $(document).ready(function(){
      $("#date").inputmask("99/99/9999",{ "placeholder": "dd/mm/yyyy", clearMaskOnLostFocus: false});
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Document</title>
      <script src="https://cdn.jsdelivr.net/gh/RobinHerbots/jquery.inputmask@5.0.6/dist/jquery.inputmask.min.js" type="text/javascript"></script>
    </head>
    <body>
      <input id="date" type="text" value="" />
    </body>
    </html>