admin管理员组文章数量:1428513
I have this piece of code that uses jquery datepicker and jquery masked input.
jQuery(function($) {
$(document).on('click', '#date', function () {
var me = $("#date");
me.datepicker({
showOn: 'focus',
altFormat: "mm/dd/yy",
dateFormat: "mm/dd/yy",
minDate: '12/12/2000',
maxDate: '12/12/2020'
}).focus();
me.mask('99/99/9999');
}).on('select', '#date', function () {
var me = $("#date");
me.mask('99/99/9999');
});
});
JSFiddle
The code uses jquery on because the input element in the application is dynamically added into the page. And the masked input is also registered from select
event because user can e to the input by pressing tab from previous input.
It doesn't work on Firefox 31
, but it works fine on Chrome 36
and IE 11
.
When the input field is empty, user should be able to type anything (based on masked filter) in the input element.
Kindly suggest me what's wrong with the code.
I have this piece of code that uses jquery datepicker and jquery masked input.
jQuery(function($) {
$(document).on('click', '#date', function () {
var me = $("#date");
me.datepicker({
showOn: 'focus',
altFormat: "mm/dd/yy",
dateFormat: "mm/dd/yy",
minDate: '12/12/2000',
maxDate: '12/12/2020'
}).focus();
me.mask('99/99/9999');
}).on('select', '#date', function () {
var me = $("#date");
me.mask('99/99/9999');
});
});
JSFiddle
The code uses jquery on because the input element in the application is dynamically added into the page. And the masked input is also registered from select
event because user can e to the input by pressing tab from previous input.
It doesn't work on Firefox 31
, but it works fine on Chrome 36
and IE 11
.
When the input field is empty, user should be able to type anything (based on masked filter) in the input element.
Kindly suggest me what's wrong with the code.
Share Improve this question edited Aug 5, 2014 at 10:43 Yuliam Chandra asked Aug 5, 2014 at 10:32 Yuliam ChandraYuliam Chandra 14.7k12 gold badges55 silver badges69 bronze badges 2- 1 Try this jsfiddle/6Z2Ws/2 – Aamir Afridi Commented Aug 5, 2014 at 11:05
- 1 @AamirAfridi, I appreciated the help, but the mask is also required when the input is activated from another input (e.g. pressing tab from previous input), anyway I already solve it, thx – Yuliam Chandra Commented Aug 5, 2014 at 11:06
1 Answer
Reset to default 0Just fixed it by changing the select
into focus
, I can't remember why I used select
in the first place.
jQuery(function($) {
$(document).on('click', '#date', function () {
var me = $("#date");
me.datepicker({
showOn: 'focus',
altFormat: "mm/dd/yy",
dateFormat: "mm/dd/yy",
minDate: '12/12/2000',
maxDate: '12/12/2020'
}).focus();
}).on('focus', '#date', function () {
var me = $("#date");
me.mask('99/99/9999');
});
});
Fixed JSFiddle
本文标签: javascriptjquery datepicker and jquery mask not workingStack Overflow
版权声明:本文标题:javascript - jquery datepicker and jquery mask not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745424735a2658057.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论