我如何使+仅出现一次,只在前面出现,例如regex jquery中的示例+01234564789。 [英] How do I make + only appear once and at the front only like example +01234564789 in regex jquery.
问题描述
如何使+仅出现一次,只在前面出现,例如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屋!