javascript 如何从 jQuery 输入掩码插件文本框中删除下划线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32688102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove underline from jQuery input mask plugin textboxes
提问by nickalchemist
I want to remove underline from masked input implemented using jQuery inputmask plugin- http://github.com/RobinHerbots/jquery.inputmask
我想从使用 jQuery inputmask 插件实现的屏蔽输入中删除下划线 - http://github.com/RobinHerbots/jquery.inputmask
采纳答案by Ori Drori
To remove the mask, use the placeholder
option. Assigning an empty string to placeholder, removes the mask. You can assign the placeholder when creating the mask:
要移除遮罩,请使用该placeholder
选项。为占位符分配一个空字符串,删除掩码。您可以在创建蒙版时分配占位符:
$('input').inputmask("mask name", {"placeholder": ""});
Or change it afterwards:
或者之后更改它:
$('input').inputmask({"placeholder": ""});
回答by Horacio Escoto
You can also use data-placeholder="" and initialize just like that. Regards
您也可以使用 data-placeholder="" 并像这样初始化。问候
P.D: I'm using Jasny : http://www.jasny.net/bootstrap/javascript/#inputmask-examples
PD:我正在使用 Jasny:http: //www.jasny.net/bootstrap/javascript/#inputmask-examples
回答by Bas van Stein
You can specify the placeholder (by default _) like this:
您可以像这样指定占位符(默认为 _):
$(document).ready(function(){
$("#date").inputmask("d/m/y",{ "placeholder": "dd/mm/yyyy" });
});
The placeholder can also be a single character, in that case it is repeated for the whole length of your input.
占位符也可以是单个字符,在这种情况下,它会在您输入的整个长度内重复。
$(document).ready(function(){
$("#code").inputmask("aaaa",{ "placeholder": "*" });
});
So to remove it you specify an empty placeholder like:
因此,要删除它,请指定一个空的占位符,例如:
$(document).ready(function(){
$("#noplaceholder").inputmask("aaaa",{ "placeholder": "" });
});
回答by WisdmLabs
$(document).ready(function(){
$('#code').inputmask({ "placeholder": "" });
$( "#code" ).focus(function() {
$('#code').inputmask({ "placeholder": "" });
});
});
If it is showing on focus event as well then try this
如果它也显示在焦点事件上,那么试试这个
回答by Basheer AL-MOMANI
this is my html element
这是我的 html 元素
<input dir="ltr" type="tel" name="SecretaryPhone">
and in my jquery
在我的 jquery
$('input[type="tel"]').mask('(999) 999-9999', { placeholder: "X" });
and the result is what I wanted
结果就是我想要的
but on some versions (I don't know it) the replacment technique is defendant,
但在某些版本(我不知道)中,替换技术是被告,
you have to put placeholder like this
你必须像这样放置占位符
{ placeholder: "(XXX) XXX-XXXX" }
回答by mister_smythers
Maybe this will help.
也许这会有所帮助。
When clearMaskOnLostFocus: true is set in the options (default), the mask will clear out the optional part when it is not filled in and this only in case the optional part is at the end of the mask.
当在选项中设置 clearMaskOnLostFocus: true 时(默认),掩码将在未填写时清除可选部分,这仅在可选部分位于掩码末尾的情况下。
For example, given:
例如,给定:
$('#test').inputmask('999[-AAA]');
While the field has focus and is blank, users will see the full mask -. When the required part of the mask is filled and the field loses focus, the user will see 123. When both the required and optional parts of the mask are filled out and the field loses focus, the user will see 123-ABC.
当该字段具有焦点且为空白时,用户将看到完整的掩码-。当掩码的必填部分被填满并且字段失去焦点时,用户将看到123。当掩码的必填部分和可选部分都填写并且字段失去焦点时,用户将看到123-ABC。
This is in the documentation here.
这在此处的文档中。
Here's an example:
下面是一个例子:
$("#whatever").inputmask("a{0,4}", {
clearMaskOnLostFocus: true
});