目次

ニュース

日記カテゴリ

書庫

   1: $(function () {
   2:     $("#bt").click(function() {
   3:     var text = $("#text").val();
   4:     var res = text.match(/\d{3}-\d{4}-\d/);
   5:     if (res != null) {
   6:         alert(true);
   7:     }
   8:     else {
   9:         if (text.length == 8) {
  10:             alert(text.replace(/(\d{3})(\d{4})(\d)/, "$1-$2-$3"));
  11:         }
  12:     }
  13:     });
  14: });

 

本当はstring.insert的なものがあればとか思ったのだけれどもないので。
簡易的なものだけれども電話番号とかもいけそう。

投稿日時 : 2011年9月14日 23:19
Feedback
No comments posted yet.
タイトル
名前
Url
コメント 

Blog 利用状況

  • 投稿数 - 173
  • 記事 - 1
  • コメント - 6244
  • トラックバック - 20