Skip to content

Instantly share code, notes, and snippets.

@shoyan
Created December 5, 2012 00:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoyan/4210849 to your computer and use it in GitHub Desktop.
Save shoyan/4210849 to your computer and use it in GitHub Desktop.
jsの日本語バリデーションサンプル
var wPat = "[a-zA-Z0-9-]"; // 英数字・ハイフン
wPat += "|[\u3041-\u3093]"; // ひらがな
wPat += "|[\u30A1-\u30F6]"; // カタカナ
wPat += "|[・ヽヾゝゞ々ー]"; // 記号
wPat += "|[\u4E00-\u9FFF]"; //漢字
wPat = "^(" + wPat +")+$";
if (!str.match(wPat)) {
return false;
}
return true;
@gktac
Copy link

gktac commented Sep 1, 2022

マジ助かりました、ありがとナス!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment