Masked Input Plugin with default value

I use digitalbush a hidden input plugin , 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="DD/MM/YYYY" onfocus="this.value = this.value=='DD/MM/YYYY'?'':this.value;" onblur="this.value = this.value==''?'DD/MM /YYYY':this.value;"> 

but after applying disguise through

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

The default HTML value no longer works.

0
source share
1 answer

Take a look at this script: http://jsfiddle.net/tuliomonteazul/EGUcj/

To fix the default value when loading the page, I just commented on the last call to checkVal(); . And to fix onblur, to apply the default value, I commented on checkVal(); inside .bind('blur.mask') and changed the onblur function in the input.

I think that the license of the plugin allows you to change its code.

+4
source

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


All Articles