在javascript中允许带有西班牙语正则表达式的字母数字? [英] Allow alphanumeric with spanish regex in javascript?
本文介绍了在javascript中允许带有西班牙语正则表达式的字母数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 javascript 中尝试了以下代码,
Hi I tried the following code in javascript,
if(/[^0-9a-zñáéíóúü]/i.test(string))
{
alert("oK WITH THE INPUT");
}
else
{
alert("error");
}
但我得到的结果是 OK ,即使我在字符串中输入了 @ 字符.我不知道为什么.
But I am getting a result OK , even I entered the @ characters in my string. I dont why.
我的目标是允许使用字母数字(英语和西班牙语).
My aim is to allow alphanumeric(English and spanish).
请帮我解决这个问题.
提前致谢.
推荐答案
if(/^[0-9a-zñáéíóúü]+$/i.test(string))
{
alert("oK WITH THE INPUT");
}
else
{
alert("error");
}
查看全文