我正在使用 meioMask – a jQuery mask插件,用于在文本框中放置时间掩码.这是 JsFiddle .运作良好.但是我还需要在文本框中输入hh:mm,以使用户知道在文本框中输入什么.
I am using meioMask – a jQuery mask plugin to put time mask in a textbox. Here is the JsFiddle. It's working well. But I also need to put hh:mm in the textbox, to let the user know what to enter in the textbox.
如何做到这一点.
编辑:我还需要将am/pm放在掩码中.我需要12个小时的时间格式.
I also need to put am/pm in the mask. and I need 12 hrs time format.
推荐答案您似乎应该可以使用插件进行设置.
It looks like you should be able to set this with the plugin.
也许这是一个开始?
如果您在代码中查找,我认为您应该将setMask和options对象传递给它.看来defaultValue是可能的选择.
If you look in the code, I think you should be passing setMask an options object. It looks like defaultValue is a possible option.
以下内容应该可以工作(但不可以):
It looks like the following should work (but it doesn't):
$("#txtTime").setMask({mask: "time", defaultValue:"hh:mm"});这就是我正在查看的内容:
This is what I was looking at:
$.fn.extend({ setMask : function(options){ return $.mask.set(this, options); },还有
// default settings for the plugin options : { attr: 'alt', // an attr to look for the mask name or the mask itself mask: null, // the mask to be used on the input type: 'fixed', // the mask of this mask maxLength: -1, // the maxLength of the mask defaultValue: '', // the default value for this input更多推荐
使用jQuery输入时间掩码
发布评论