1
我试过在这个正则表达式的不同位置放置一个撇号,但我仍然收到错误。我需要把它放在哪里?如何添加撇号到jQuery验证正则表达式?
$.validator.addMethod("customvalidation",
function(value, element) {
return (/^[A-Za-z\d=#$%@_\-]+$/.test(value));
},
"Sorry, no special characters allowed"
);
事情我已经尝试:
//putting the apostraphe before the @ sign without escaping
(/^[A-Za-z\d=#$%'@_\-]+$/.test(value));
//putting the apostraphe as the last value in the brackets with and without escaping
(/^[A-Za-z\d=#$%'@_\- \']+$/.test(value));
没有什么特别之处正则表达式撇号。您应该可以将其添加到括号中。 – Barmar
无论我把它放在哪里,我都会收到错误,表示没有允许特殊字符 – Spilot
确保你输入了一个真正的撇号,而不是“智能报价”。 – Barmar