admin管理员组文章数量:1401509
I've been using digitalbush's masked input plugin, and I was wondering if there was any way you could add a default value to the masked fields.
I've tried adding 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 the masking via
<script type="text/javascript">
$(document).ready(function(){
$("#date").mask("99/99/9999", {placeholder:"#"});
});
</script>
The default value HTML no longer works.
I've been using digitalbush's masked input plugin, and I was wondering if there was any way you could add a default value to the masked fields.
I've tried adding 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 the masking via
<script type="text/javascript">
$(document).ready(function(){
$("#date").mask("99/99/9999", {placeholder:"#"});
});
</script>
The default value HTML no longer works.
Share Improve this question edited Feb 27, 2012 at 13:48 Octavian Helm 39.6k19 gold badges99 silver badges102 bronze badges asked Feb 27, 2012 at 13:30 user886596user886596 2,4405 gold badges37 silver badges54 bronze badges1 Answer
Reset to default 4Take a look at this fiddle: http://jsfiddle/tuliomonteazul/EGUcj/
To fix the default value when the page loads I just mented the last call of checkVal();
.
And to fix the onblur to apply the default value too, I mented the checkVal();
inside the .bind('blur.mask')
and changed the onblur
function of the input.
I think the plugin's license permits to change his code.
本文标签: javascriptMasked Input Plugin with a default valueStack Overflow
版权声明:本文标题:javascript - Masked Input Plugin with a default value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744213088a2595512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论