Masked Input Plugin removes the default value

I use the plug-in-plug-in-plug-in plug-in, and I was wondering if you could add a default value to the masked fields.

I tried to add it using:

<input id="date" type="text" value="Example: 01/02/1990" onfocus="this.value = this.value=='Example: 01/02/1990'?'':this.value;" onblur="this.value = this.value==''?'Example: 01/02/1990':this.value;"> 

but after applying disguise through

 <script type="text/javascript"> $(document).ready(function(){ $("#date").mask("99/99/9999"); }); </script> 

The default HTML value no longer works. Any suggestions?

+4
source share
1 answer

Try using this:

 <script type="text/javascript"> $(document).ready(function(){ $("#date").mask("99/99/9999"); $("#date").val("default value"); }); </script> 

Or you can save the value before applying the mask, and then restore it.

The best solution can be found here Masked Input Plugin with default value

+2
source

Source: https://habr.com/ru/post/1399580/


All Articles