使用jQuery输入时间掩码

编程入门 行业动态 更新时间:2024-10-11 17:19:32
本文介绍了使用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.

也许这是一个开始?

如果您在代码中查找,我认为您应该将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输入时间掩码

本文发布于:2023-11-13 04:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583423.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:掩码   时间   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!