我如何使+仅出现一次,只在前面出现,例如regex jquery中的示例+01234564789。 [英] How do I make + only appear once and at the front only like example +01234564789 in regex jquery.

查看:73
本文介绍了我如何使+仅出现一次,只在前面出现,例如regex jquery中的示例+01234564789。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使+仅出现一次,只在前面出现,例如Regex Jquery中的示例+01234564789。角色不能无处不在,只能在文本区域前面出现一次。



我尝试了什么:



我试过这个,但它仍有问题。所以我真的需要帮助我是初学者所以请帮助我。



$(功能(){

$(' #hpno')。keypress(function(e){

var txt = String.fromCharCode(e.which);

console.log(txt +':'+ e.which);

if(!txt.match(/ ^ \ + * / [0-9] + $ /))

{

返回false;

}

});

});

How do I make + only appear once and at the front only like example +01234564789 in Regex Jquery. The character can't be everywhere and only front and appear only once in the textfield.

What I have tried:

I have try this, but its still have problem. So I really need help I'm a beginner for this so please help me.

$(function(){
$('#hpno').keypress(function(e){
var txt = String.fromCharCode(e.which);
console.log(txt + ' : ' + e.which);
if(!txt.match(/^\+*/ [0-9]+$/))
{
return false;
}
});
});

推荐答案

(function(){
(function(){


('#hpno')。keypress(function(e){

var txt = String.fromCharCode(e.which);

console.log(txt +':'+ e.which);

if(!txt.match(/ ^ \\ \\ + * / [0-9] +
('#hpno').keypress(function(e){
var txt = String.fromCharCode(e.which);
console.log(txt + ' : ' + e.which);
if(!txt.match(/^\+*/ [0-9]+


/))

{

返回false;

}

});

});
/))
{
return false;
}
});
});


这篇关于我如何使+仅出现一次,只在前面出现,例如regex jquery中的示例+01234564789。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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