Using Inputmask jquery plugin default placeholder text not displayed

1.6k Views Asked by At

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"
});
1

There are 1 best solutions below

1
Oluwafemi Sule On BEST ANSWER

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/[email protected]/dist/jquery.inputmask.min.js" type="text/javascript"></script>
</head>
<body>
  <input id="date" type="text" value="" />
</body>
</html>