如何使用一些前缀屏蔽文本框的输入? [英] How to mask input of textbox with some prefix?

查看:91
本文介绍了如何使用一些前缀屏蔽文本框的输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图掩盖手机号码的输入,所以我正在做这样的事情

I am trying to mask the input of the mobile number so i am doing something like this

("#mobNum").mask("(+91) 999-999-9999)



此掩码相当于此输入

前缀+91然后是3位数后跟另外3位数字然后4位数。

所以它是这样的 +91 987-569-4869

所以我想要前缀( +91 )在文本框的前面自动

我怎样才能实现这个


this mask is equivalent to this input
prefix +91 then followed by 3 digits followed by another 3 digits and then 4 digits.
so it is something like this +91 987-569-4869
So i want to prefix (+91) in the front of the text box automatically
how can i achieve this

推荐答案

你可以添加一个密钥处理程序添加前缀。



You can add a keyup handler to add the prefix.


#mobNum)。keyup( function (){
var prefix = + 91

if this .value.indexOf(prefix)!== 0 ){
this .value = prefix + this .value;
}
});
("#mobNum").keyup(function(){ var prefix = "+91" if(this.value.indexOf(prefix) !== 0 ){ this.value = prefix + this.value; } });


这篇关于如何使用一些前缀屏蔽文本框的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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