使用jQuery输入时间掩码 [英] input time mask using jquery

查看:112
本文介绍了使用jQuery输入时间掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

也许这是一个开始?

如果您在代码中查找,我认为您应该将setMaskoptions对象传递给它.看来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输入时间掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆