Jquery符号位置的电话号码 [英] Jquery symbol position for phone number

查看:67
本文介绍了Jquery符号位置的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过这个新代码并且还有一个问题是如何使用可选加号(+),就像用户只能在文本的开头插入一样。喜欢当你插入

0164 +++ 1594 // false

+0123456789 // true



< br $> b $ b

Google Code Archive - Long Google代码项目托管的长期存储。 [ ^ ]



我搜索了这个,但我不明白我认为它与我想要的相似



我尝试了什么:



我尝试过这个新代码,还有一个问题如何我可以选择加号(+),就像用户只能在文本开头插入一样: -



I have tried this new code and one problem left how do I make optional plus (+) , like user only can insert in the beginning of the text. Like when you insert
0164+++1594 //false
+0123456789 // true



Google Code Archive - Long-term storage for Google Code Project Hosting.[^]

I have search this but i don't understand i think its similiar to what i want

What I have tried:

I have tried this new code and one problem left how do I make optional plus (+) , like user only can insert in the beginning of the text :-

$("#hpno").on("keypress keyup blur",function (event) {
            //this.value = this.value.replace(/[^0-9\.]/g,'');
     $(this).val($(this).val().replace(/[^\+?0-9]/g,''));
            if ((event.which != 43 || $(this).val().indexOf('+') != -1) && (event.which < 48 || event.which > 57)) {
                event.preventDefault();
            }
        });

推荐答案

#hpno)。on( keypress keyup模糊功能(事件){
// this.value = this.value.replace(/ [^ 0-9 \。] / g,'');
("#hpno").on("keypress keyup blur",function (event) { //this.value = this.value.replace(/[^0-9\.]/g,'');


(< span class =code-keyword> this )。val(


this )。val() .replace(/ [^ \ +?0-9] / g,' '));
if ((event.which!= 43 ||
(this).val().replace(/[^\+?0-9]/g,'')); if ((event.which != 43 ||


这篇关于Jquery符号位置的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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