我需要对 PHP 和 Jquery 中的 tild(~) 和 tilt(`) 字符进行良好的验证。 这是我所做的 Jquery 验证。
$.validator.addMethod("validSMS", function(value, element) {
if (value.indexOf('~') === -1 || value.indexOf('`') === -1)
{
return true;
}
else
{
return false;
}
}, "Tild and tilt Character is not allowed");
但我还需要另一种在 Jquery 和 PHP 中进行验证的好方法。
最佳答案
这是php版本,使用strpos
if (strrpos($mystring, "~") === false && strrpos($mystring, "`") === false ) {
// $mystring has no tild(~) and tilt(`) chars
}
关于php - PHP 和 Jquery 中倾斜和倾斜字符的自定义验证规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14745948/