我正在尝试检测文本输入字段是否有任何不属于 GSM 7 位字母表的字符。带有字符的表格在这里http://www.dreamfabric.com/sms/default_alphabet.html
经过大量搜索后,我发现这个(我需要什么正则表达式来检查一些非拉丁字符?)它非常接近我想要完成的,因为它检测到非拉丁字符。如何更改正则表达式以包含 GSM 7 位字母?
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>test foreign chars</title>
</head>
<body>
<input id="foreign_characters" size="12" type="text" name="foreign_characters" value="test">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
(function(){
$('#foreign_characters').on("keyup", function(){
var foreignCharacters = $("#foreign_characters").val();
var rforeign = /[^\u0000-\u007f]/;
if (rforeign.test(foreignCharacters)) {
alert("This is non-Latin Characters");
} else {
alert("This is Latin Characters");
}
});
})();
</script>
</body>
</html>