`
salute
  • 浏览: 55055 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

项目常用check

 
阅读更多

/****************************************************************
* 機 能:  //電話番号数字又は’-’のみ入力可:00-0000-0000形式
****************************************************************/

  if(telno!=null && telno!=""){ 
     var pattern= /^(([0-9]{2})-([0-9]{4})-([0-9]{4}))$/;
var result = pattern.test(telno);
if(result == false){
alert('電話番号は数字又は’-’のみを「06-8888-8888」ようなフォームで入力して下さい。');
   $("#telno").attr("value","");
    $("#telno").focus();

return false;
}
  }

/****************************************************************
* 機 能:   //郵便番号数字チェック:000-0000形式
****************************************************************/

    var postCode = $("#postCode").val();
    if(postCode!=null && postCode!=""){
     var pattern=/^((^([0-9]{3})-([0-9]{4})$)|(^[0-9]{7}$))$/;
var result = pattern.test(postCode);
if(result == false){
alert('郵便番号は数字又は’-’のみを「666-8888」まだは「6668888」ようなフォームで入力して下さい。');
$("#postCode").attr("value","");
$("#postCode").focus();
return false;
  }
  }

/****************************************************************
* 機 能: 全角は半角へ転換処理
****************************************************************/

  function CtoH(obj){
  var str=obj.value;
  var result="";
  for (var i = 0; i < str.length; i++){
   if (str.charCodeAt(i)==12288){
    result+= String.fromCharCode(str.charCodeAt(i)-12256);
    continue;
  }
  if (str.charCodeAt(i)>65280 && str.charCodeAt(i)<65375) {
      result+= String.fromCharCode(str.charCodeAt(i)-65248);
      }
  else {
      result+= String.fromCharCode(str.charCodeAt(i));
      }
  }
  obj.value=result;
  }


/****************************************************************
* 機 能: //◆半角は全角に変更して入力****************************************************************/  

  function HtoC(obj){
  alert("HtoC");
  var str=obj.value;
  var result="";
  for (var i = 0; i < str.length; i++){
    code = str.charCodeAt(i);
  if (code >= 33 && code <= 126)
    {
     result += String.fromCharCode(str.charCodeAt(i) + 65248);
    }else if (code == 32)
    {
    result += String.fromCharCode(str.charCodeAt(i) - 32 + 12288);
    }else
    {
    result += str.charAt(i);
     }
    }
     obj.value=result;
     return true;
   }


/****************************************************************
* 機 能: //◆半角カナかどうか、判断する****************************************************************/

function isHalfKana(value){
    if(value == null || value == ''){
            return value;
    }
    var iCount;
    var iCode;
    for (iCount=0 ; iCount<value.length ; iCount++){
                iCode = value.charCodeAt(iCount);
                  if (iCode < 0xff61 || iCode > 0xff9f){
        return "";
            }
    }
    return value;
}
 

/****************************************************************
* 機 能: //姓名(フリガナ) ◆半角カナに変更して入力****************************************************************/


function namekanainputCheck(obj){
   var str="";
   var s = ""; 
    s = obj.value;
    while(s.indexOf("あ")!=-1){s=s.replace("あ","ア");}
    while(s.indexOf("い")!=-1){s=s.replace("い","イ");}
    while(s.indexOf("う")!=-1){s=s.replace("う","ウ");}
    while(s.indexOf("え")!=-1){s=s.replace("え","エ");}
    while(s.indexOf("お")!=-1){s=s.replace("お","オ");}
    while(s.indexOf("か")!=-1){s=s.replace("か","カ");}
    while(s.indexOf("き")!=-1){s=s.replace("き","キ");}
    while(s.indexOf("く")!=-1){s=s.replace("く","ク");}
    while(s.indexOf("け")!=-1){s=s.replace("け","ケ");}
    while(s.indexOf("こ")!=-1){s=s.replace("こ","コ");}
    while(s.indexOf("さ")!=-1){s=s.replace("さ","サ");}
    while(s.indexOf("し")!=-1){s=s.replace("し","シ");}
    while(s.indexOf("す")!=-1){s=s.replace("す","ス");}
    while(s.indexOf("せ")!=-1){s=s.replace("せ","セ");}
    while(s.indexOf("そ")!=-1){s=s.replace("そ","ソ");}
    while(s.indexOf("た")!=-1){s=s.replace("た","タ");}
    while(s.indexOf("ち")!=-1){s=s.replace("ち","チ");}
    while(s.indexOf("つ")!=-1){s=s.replace("つ","ツ");}
    while(s.indexOf("て")!=-1){s=s.replace("て","テ");}
    while(s.indexOf("と")!=-1){s=s.replace("と","ト");}
    while(s.indexOf("な")!=-1){s=s.replace("な","ナ");}
    while(s.indexOf("に")!=-1){s=s.replace("に","ニ");}
    while(s.indexOf("ぬ")!=-1){s=s.replace("ぬ","ヌ");}
    while(s.indexOf("ね")!=-1){s=s.replace("ね","ネ");}
    while(s.indexOf("の")!=-1){s=s.replace("の","ノ");}
    while(s.indexOf("は")!=-1){s=s.replace("は","ハ");}
    while(s.indexOf("ひ")!=-1){s=s.replace("ひ","ヒ");}
    while(s.indexOf("ふ")!=-1){s=s.replace("ふ","フ");}
    while(s.indexOf("へ")!=-1){s=s.replace("へ","ヘ");}
    while(s.indexOf("ほ")!=-1){s=s.replace("ほ","ホ");}
    while(s.indexOf("ま")!=-1){s=s.replace("ま","マ");}
    while(s.indexOf("み")!=-1){s=s.replace("み","ミ");}
    while(s.indexOf("む")!=-1){s=s.replace("む","ム");}
    while(s.indexOf("め")!=-1){s=s.replace("め","メ");}
    while(s.indexOf("も")!=-1){s=s.replace("も","モ");}
    while(s.indexOf("や")!=-1){s=s.replace("や","ヤ");}
    while(s.indexOf("ゆ")!=-1){s=s.replace("ゆ","ユ");}
    while(s.indexOf("よ")!=-1){s=s.replace("よ","ヨ");}
    while(s.indexOf("ら")!=-1){s=s.replace("ら","ラ");}
    while(s.indexOf("り")!=-1){s=s.replace("り","リ");}
    while(s.indexOf("る")!=-1){s=s.replace("る","ル");}
    while(s.indexOf("れ")!=-1){s=s.replace("れ","レ");}
    while(s.indexOf("ろ")!=-1){s=s.replace("ろ","ロ");}
    while(s.indexOf("わ")!=-1){s=s.replace("わ","ワ");}
    while(s.indexOf("を")!=-1){s=s.replace("を","ヲ");}
    while(s.indexOf("ん")!=-1){s=s.replace("ん","ン");}
    while(s.indexOf("ゃ")!=-1){s=s.replace("ゃ","ャ");}
    while(s.indexOf("ゅ")!=-1){s=s.replace("ゅ","ュ");}
    while(s.indexOf("ょ")!=-1){s=s.replace("ょ","ョ");}   
    while(s.indexOf("ア")!=-1){s=s.replace("ア","ア");}
    while(s.indexOf("イ")!=-1){s=s.replace("イ","イ");}
    while(s.indexOf("ウ")!=-1){s=s.replace("ウ","ウ");}
    while(s.indexOf("エ")!=-1){s=s.replace("エ","エ");}
    while(s.indexOf("オ")!=-1){s=s.replace("オ","オ");}
    while(s.indexOf("カ")!=-1){s=s.replace("カ","カ");}
    while(s.indexOf("キ")!=-1){s=s.replace("キ","キ");}
    while(s.indexOf("ク")!=-1){s=s.replace("ク","ク");}
    while(s.indexOf("ケ")!=-1){s=s.replace("ケ","ケ");}
    while(s.indexOf("コ")!=-1){s=s.replace("コ","コ");}
    while(s.indexOf("サ")!=-1){s=s.replace("サ","サ");}
    while(s.indexOf("シ")!=-1){s=s.replace("シ","シ");}
    while(s.indexOf("ス")!=-1){s=s.replace("ス","ス");}
    while(s.indexOf("セ")!=-1){s=s.replace("セ","セ");}
    while(s.indexOf("ソ")!=-1){s=s.replace("ソ","ソ");}
    while(s.indexOf("タ")!=-1){s=s.replace("タ","タ");}
    while(s.indexOf("チ")!=-1){s=s.replace("チ","チ");}
    while(s.indexOf("ツ")!=-1){s=s.replace("ツ","ツ");}
    while(s.indexOf("テ")!=-1){s=s.replace("テ","テ");}
    while(s.indexOf("ト")!=-1){s=s.replace("ト","ト");}
    while(s.indexOf("ナ")!=-1){s=s.replace("ナ","ナ");}
    while(s.indexOf("ニ")!=-1){s=s.replace("ニ","ニ");}
    while(s.indexOf("ヌ")!=-1){s=s.replace("ヌ","ヌ");}
    while(s.indexOf("ネ")!=-1){s=s.replace("ネ","ネ");}
    while(s.indexOf("ノ")!=-1){s=s.replace("ノ","ノ");}
    while(s.indexOf("ハ")!=-1){s=s.replace("ハ","ハ");}
    while(s.indexOf("ヒ")!=-1){s=s.replace("ヒ","ヒ");}
    while(s.indexOf("フ")!=-1){s=s.replace("フ","フ");}
    while(s.indexOf("ヘ")!=-1){s=s.replace("ヘ","ヘ");}
    while(s.indexOf("ホ")!=-1){s=s.replace("ホ","ホ");}
    while(s.indexOf("マ")!=-1){s=s.replace("マ","マ");}
    while(s.indexOf("ミ")!=-1){s=s.replace("ミ","ミ");}
    while(s.indexOf("ム")!=-1){s=s.replace("ム","ム");}
    while(s.indexOf("メ")!=-1){s=s.replace("メ","メ");}
    while(s.indexOf("モ")!=-1){s=s.replace("モ","モ");}
    while(s.indexOf("ヤ")!=-1){s=s.replace("ヤ","ヤ");}
    while(s.indexOf("ユ")!=-1){s=s.replace("ユ","ユ");}
    while(s.indexOf("ヨ")!=-1){s=s.replace("ヨ","ヨ");}
    while(s.indexOf("ラ")!=-1){s=s.replace("ラ","ラ");}
    while(s.indexOf("リ")!=-1){s=s.replace("リ","リ");}
    while(s.indexOf("ル")!=-1){s=s.replace("ル","ル");}
    while(s.indexOf("レ")!=-1){s=s.replace("レ","レ");}
    while(s.indexOf("ロ")!=-1){s=s.replace("ロ","ロ");}
    while(s.indexOf("ワ")!=-1){s=s.replace("ワ","ワ");}
    while(s.indexOf("ヲ")!=-1){s=s.replace("ヲ","ヲ");}
    while(s.indexOf("ン")!=-1){s=s.replace("ン","ン");}
    while(s.indexOf("ャ")!=-1){s=s.replace("ャ","ャ");}
    while(s.indexOf("ュ")!=-1){s=s.replace("ュ","ュ");}
    while(s.indexOf("ョ")!=-1){s=s.replace("ョ","ョ");}   
    while(s.indexOf("が")!=-1){s=s.replace("が","ガ");}
    while(s.indexOf("ぎ")!=-1){s=s.replace("ぎ","ギ");}
    while(s.indexOf("ぐ")!=-1){s=s.replace("ぐ","グ");}
    while(s.indexOf("げ")!=-1){s=s.replace("げ","ゲ");}
    while(s.indexOf("ご")!=-1){s=s.replace("ご","ゴ");}   
    while(s.indexOf("ざ")!=-1){s=s.replace("ざ","ザ");}
    while(s.indexOf("じ")!=-1){s=s.replace("じ","ジ");}
    while(s.indexOf("ず")!=-1){s=s.replace("ず","ズ");}
    while(s.indexOf("ぜ")!=-1){s=s.replace("ぜ","ゼ");}
    while(s.indexOf("ぞ")!=-1){s=s.replace("ぞ","ゾ");}   
    while(s.indexOf("だ")!=-1){s=s.replace("だ","ダ");}
    while(s.indexOf("ぢ")!=-1){s=s.replace("ぢ","ヂ");}
    while(s.indexOf("づ")!=-1){s=s.replace("づ","ヅ");}
    while(s.indexOf("で")!=-1){s=s.replace("で","デ");}
    while(s.indexOf("ど")!=-1){s=s.replace("ど","ド");}   
    while(s.indexOf("ば")!=-1){s=s.replace("ば","バ");}
    while(s.indexOf("び")!=-1){s=s.replace("び","ビ");}
    while(s.indexOf("ぶ")!=-1){s=s.replace("ぶ","ブ");}
    while(s.indexOf("べ")!=-1){s=s.replace("べ","ベ");}
    while(s.indexOf("ぼ")!=-1){s=s.replace("ぼ","ボ");}
   
    while(s.indexOf("ぱ")!=-1){s=s.replace("ぱ","パ");}
    while(s.indexOf("ぴ")!=-1){s=s.replace("ぴ","ピ");}
    while(s.indexOf("ぷ")!=-1){s=s.replace("ぷ","プ");}
    while(s.indexOf("ぺ")!=-1){s=s.replace("ぺ","ペ");}
    while(s.indexOf("ぽ")!=-1){s=s.replace("ぽ","ポ");}
   
    while(s.indexOf("ガ")!=-1){s=s.replace("ガ","ガ");}
    while(s.indexOf("ギ")!=-1){s=s.replace("ギ","ギ");}
    while(s.indexOf("グ")!=-1){s=s.replace("グ","グ");}
    while(s.indexOf("ゲ")!=-1){s=s.replace("ゲ","ゲ");}
    while(s.indexOf("ゴ")!=-1){s=s.replace("ゴ","ゴ");}
   
    while(s.indexOf("ザ")!=-1){s=s.replace("ザ","ザ");}
    while(s.indexOf("ジ")!=-1){s=s.replace("ジ","ジ");}
    while(s.indexOf("ズ")!=-1){s=s.replace("ズ","ズ");}
    while(s.indexOf("ゼ")!=-1){s=s.replace("ゼ","ゼ");}
    while(s.indexOf("ゾ")!=-1){s=s.replace("ゾ","ゾ");}
   
    while(s.indexOf("ダ")!=-1){s=s.replace("ダ","ダ");}
    while(s.indexOf("ヂ")!=-1){s=s.replace("ヂ","ヂ");}
    while(s.indexOf("ヅ")!=-1){s=s.replace("ヅ","ヅ");}
    while(s.indexOf("デ")!=-1){s=s.replace("デ","デ");}
    while(s.indexOf("ド")!=-1){s=s.replace("ド","ド");}
   
    while(s.indexOf("バ")!=-1){s=s.replace("バ","バ");}
    while(s.indexOf("ビ")!=-1){s=s.replace("ビ","ビ");}
    while(s.indexOf("ブ")!=-1){s=s.replace("ブ","ブ");}
    while(s.indexOf("ベ")!=-1){s=s.replace("ベ","ベ");}
    while(s.indexOf("ボ")!=-1){s=s.replace("ボ","ボ");}
   
    while(s.indexOf("パ")!=-1){s=s.replace("パ","パ");}
    while(s.indexOf("ピ")!=-1){s=s.replace("ピ","ピ");}
    while(s.indexOf("プ")!=-1){s=s.replace("プ","プ");}
    while(s.indexOf("ペ")!=-1){s=s.replace("ペ","ペ");}
    while(s.indexOf("ポ")!=-1){s=s.replace("ポ","ポ");}
   obj.value = s;  
    
}


/****************************************************************
* 機 能: ////全角カナに変更して入力****************************************************************/

/全角に変更して
function KatakanaToHiragana(obj){

var s = "";
    s = obj.value;
while(s.indexOf("ア")!=-1){s=s.replace("ア","あ");}
    while(s.indexOf("イ")!=-1){s=s.replace("イ","い");}
    while(s.indexOf("ウ")!=-1){s=s.replace("ウ","う");}
    while(s.indexOf("エ")!=-1){s=s.replace("エ","え");}
    while(s.indexOf("オ")!=-1){s=s.replace("オ","お");}
    while(s.indexOf("カ")!=-1){s=s.replace("カ","か");}
    while(s.indexOf("キ")!=-1){s=s.replace("キ","き");}
    while(s.indexOf("ク")!=-1){s=s.replace("ク","く");}
    while(s.indexOf("ケ")!=-1){s=s.replace("ケ","け");}
    while(s.indexOf("コ")!=-1){s=s.replace("コ","こ");}
    while(s.indexOf("サ")!=-1){s=s.replace("サ","さ");}
    while(s.indexOf("シ")!=-1){s=s.replace("シ","し");}
    while(s.indexOf("ス")!=-1){s=s.replace("ス","す");}
    while(s.indexOf("セ")!=-1){s=s.replace("セ","せ");}
    while(s.indexOf("ソ")!=-1){s=s.replace("ソ","そ");}
    while(s.indexOf("タ")!=-1){s=s.replace("タ","た");}
    while(s.indexOf("チ")!=-1){s=s.replace("チ","ち");}
    while(s.indexOf("ツ")!=-1){s=s.replace("ツ","つ");}
    while(s.indexOf("テ")!=-1){s=s.replace("テ","て");}
    while(s.indexOf("ト")!=-1){s=s.replace("ト","と");}
    while(s.indexOf("ナ")!=-1){s=s.replace("ナ","な");}
    while(s.indexOf("ニ")!=-1){s=s.replace("ニ","に");}
    while(s.indexOf("ヌ")!=-1){s=s.replace("ヌ","ぬ");}
    while(s.indexOf("ネ")!=-1){s=s.replace("ネ","ね");}
    while(s.indexOf("ノ")!=-1){s=s.replace("ノ","の");}
    while(s.indexOf("ハ")!=-1){s=s.replace("ハ","は");}
    while(s.indexOf("ヒ")!=-1){s=s.replace("ヒ","ひ");}
    while(s.indexOf("フ")!=-1){s=s.replace("フ","ふ");}
    while(s.indexOf("ヘ")!=-1){s=s.replace("ヘ","へ");}
    while(s.indexOf("ホ")!=-1){s=s.replace("ホ","ほ");}
    while(s.indexOf("マ")!=-1){s=s.replace("マ","ま");}
    while(s.indexOf("ミ")!=-1){s=s.replace("ミ","み");}
    while(s.indexOf("ム")!=-1){s=s.replace("ム","む");}
    while(s.indexOf("メ")!=-1){s=s.replace("メ","め");}
    while(s.indexOf("モ")!=-1){s=s.replace("モ","も");}
    while(s.indexOf("ヤ")!=-1){s=s.replace("ヤ","や");}
    while(s.indexOf("ユ")!=-1){s=s.replace("ユ","ゆ");}
    while(s.indexOf("ヨ")!=-1){s=s.replace("ヨ","よ");}
    while(s.indexOf("ラ")!=-1){s=s.replace("ラ","ら");}
    while(s.indexOf("リ")!=-1){s=s.replace("リ","り");}
    while(s.indexOf("ル")!=-1){s=s.replace("ル","る");}
    while(s.indexOf("レ")!=-1){s=s.replace("レ","れ");}
    while(s.indexOf("ロ")!=-1){s=s.replace("ロ","ろ");}
    while(s.indexOf("ワ")!=-1){s=s.replace("ワ","わ");}
    while(s.indexOf("ヲ")!=-1){s=s.replace("ヲ","を");}
    while(s.indexOf("ン")!=-1){s=s.replace("ン","ん");}
    while(s.indexOf("ャ")!=-1){s=s.replace("ャ","ゃ");}
    while(s.indexOf("ュ")!=-1){s=s.replace("ュ","ゅ");}
    while(s.indexOf("ョ")!=-1){s=s.replace("ョ","ょ");}   
    while(s.indexOf("ア")!=-1){s=s.replace("ア","ア");}
    while(s.indexOf("イ")!=-1){s=s.replace("イ","イ");}
    while(s.indexOf("ウ")!=-1){s=s.replace("ウ","ウ");}
    while(s.indexOf("エ")!=-1){s=s.replace("エ","エ");}
    while(s.indexOf("オ")!=-1){s=s.replace("オ","オ");}
    while(s.indexOf("カ")!=-1){s=s.replace("カ","カ");}
    while(s.indexOf("キ")!=-1){s=s.replace("キ","キ");}
    while(s.indexOf("ク")!=-1){s=s.replace("ク","ク");}
    while(s.indexOf("ケ")!=-1){s=s.replace("ケ","ケ");}
    while(s.indexOf("コ")!=-1){s=s.replace("コ","コ");}
    while(s.indexOf("サ")!=-1){s=s.replace("サ","サ");}
    while(s.indexOf("シ")!=-1){s=s.replace("シ","シ");}
    while(s.indexOf("ス")!=-1){s=s.replace("ス","ス");}
    while(s.indexOf("セ")!=-1){s=s.replace("セ","セ");}
    while(s.indexOf("ソ")!=-1){s=s.replace("ソ","ソ");}
    while(s.indexOf("タ")!=-1){s=s.replace("タ","タ");}
    while(s.indexOf("チ")!=-1){s=s.replace("チ","チ");}
    while(s.indexOf("ツ")!=-1){s=s.replace("ツ","ツ");}
    while(s.indexOf("テ")!=-1){s=s.replace("テ","テ");}
    while(s.indexOf("ト")!=-1){s=s.replace("ト","ト");}
    while(s.indexOf("ナ")!=-1){s=s.replace("ナ","ナ");}
    while(s.indexOf("ニ")!=-1){s=s.replace("ニ","ニ");}
    while(s.indexOf("ヌ")!=-1){s=s.replace("ヌ","ヌ");}
    while(s.indexOf("ネ")!=-1){s=s.replace("ネ","ネ");}
    while(s.indexOf("ノ")!=-1){s=s.replace("ノ","ノ");}
    while(s.indexOf("ハ")!=-1){s=s.replace("ハ","ハ");}
    while(s.indexOf("ヒ")!=-1){s=s.replace("ヒ","ヒ");}
    while(s.indexOf("フ")!=-1){s=s.replace("フ","フ");}
    while(s.indexOf("ヘ")!=-1){s=s.replace("ヘ","ヘ");}
    while(s.indexOf("ホ")!=-1){s=s.replace("ホ","ホ");}
    while(s.indexOf("マ")!=-1){s=s.replace("マ","マ");}
    while(s.indexOf("ミ")!=-1){s=s.replace("ミ","ミ");}
    while(s.indexOf("ム")!=-1){s=s.replace("ム","ム");}
    while(s.indexOf("メ")!=-1){s=s.replace("メ","メ");}
    while(s.indexOf("モ")!=-1){s=s.replace("モ","モ");}
    while(s.indexOf("ヤ")!=-1){s=s.replace("ヤ","ヤ");}
    while(s.indexOf("ユ")!=-1){s=s.replace("ユ","ユ");}
    while(s.indexOf("ヨ")!=-1){s=s.replace("ヨ","ヨ");}
    while(s.indexOf("ラ")!=-1){s=s.replace("ラ","ラ");}
    while(s.indexOf("リ")!=-1){s=s.replace("リ","リ");}
    while(s.indexOf("ル")!=-1){s=s.replace("ル","ル");}
    while(s.indexOf("レ")!=-1){s=s.replace("レ","レ");}
    while(s.indexOf("ロ")!=-1){s=s.replace("ロ","ロ");}
    while(s.indexOf("ワ")!=-1){s=s.replace("ワ","ワ");}
    while(s.indexOf("ヲ")!=-1){s=s.replace("ヲ","ヲ");}
    while(s.indexOf("ン")!=-1){s=s.replace("ン","ン");}
    while(s.indexOf("ャ")!=-1){s=s.replace("ャ","ャ");}
    while(s.indexOf("ュ")!=-1){s=s.replace("ュ","ュ");}
    while(s.indexOf("ョ")!=-1){s=s.replace("ョ","ョ");}
  
    while(s.indexOf("ガ")!=-1){s=s.replace("ガ","が");}
    while(s.indexOf("ギ")!=-1){s=s.replace("ギ","ぎ");}
    while(s.indexOf("グ")!=-1){s=s.replace("グ","ぐ");}
    while(s.indexOf("ゲ")!=-1){s=s.replace("ゲ","げ");}
    while(s.indexOf("ゴ")!=-1){s=s.replace("ゴ","ご");}
  
    while(s.indexOf("ザ")!=-1){s=s.replace("ザ","ざ");}
    while(s.indexOf("ジ")!=-1){s=s.replace("ジ","じ");}
    while(s.indexOf("ズ")!=-1){s=s.replace("ズ","ず");}
    while(s.indexOf("ゼ")!=-1){s=s.replace("ゼ","ぜ");}
    while(s.indexOf("ゾ")!=-1){s=s.replace("ゾ","ぞ");}
  
    while(s.indexOf("ダ")!=-1){s=s.replace("ダ","だ");}
    while(s.indexOf("ヂ")!=-1){s=s.replace("ヂ","ぢ");}
    while(s.indexOf("ヅ")!=-1){s=s.replace("ヅ","づ");}
    while(s.indexOf("デ")!=-1){s=s.replace("デ","で");}
    while(s.indexOf("ド")!=-1){s=s.replace("ド","ど");}
  
    while(s.indexOf("バ")!=-1){s=s.replace("バ","ば");}
    while(s.indexOf("ビ")!=-1){s=s.replace("ビ","び");}
    while(s.indexOf("ブ")!=-1){s=s.replace("ブ","ぶ");}
    while(s.indexOf("ベ")!=-1){s=s.replace("ベ","べ");}
    while(s.indexOf("ボ")!=-1){s=s.replace("ボ","ぼ");}
  
    while(s.indexOf("パ")!=-1){s=s.replace("パ","ぱ");}
    while(s.indexOf("ピ")!=-1){s=s.replace("ピ","ぴ");}
    while(s.indexOf("プ")!=-1){s=s.replace("プ","ぷ");}
    while(s.indexOf("ペ")!=-1){s=s.replace("ペ","ぺ");}
    while(s.indexOf("ポ")!=-1){s=s.replace("ポ","ぽ");}
  
    while(s.indexOf("ガ")!=-1){s=s.replace("ガ","ガ");}
    while(s.indexOf("ギ")!=-1){s=s.replace("ギ","ギ");}
    while(s.indexOf("グ")!=-1){s=s.replace("グ","グ");}
    while(s.indexOf("ゲ")!=-1){s=s.replace("ゲ","ゲ");}
    while(s.indexOf("ゴ")!=-1){s=s.replace("ゴ","ゴ");}
  
    while(s.indexOf("ザ")!=-1){s=s.replace("ザ","ザ");}
    while(s.indexOf("ジ")!=-1){s=s.replace("ジ","ジ");}
    while(s.indexOf("ズ")!=-1){s=s.replace("ズ","ズ");}
    while(s.indexOf("ゼ")!=-1){s=s.replace("ゼ","ゼ");}
    while(s.indexOf("ゾ")!=-1){s=s.replace("ゾ","ゾ");}
  
    while(s.indexOf("ダ")!=-1){s=s.replace("ダ","ダ");}
    while(s.indexOf("ヂ")!=-1){s=s.replace("ヂ","ヂ");}
    while(s.indexOf("ヅ")!=-1){s=s.replace("ヅ","ヅ");}
    while(s.indexOf("デ")!=-1){s=s.replace("デ","デ");}
    while(s.indexOf("ド")!=-1){s=s.replace("ド","ド");}
  
    while(s.indexOf("バ")!=-1){s=s.replace("バ","バ");}
    while(s.indexOf("ビ")!=-1){s=s.replace("ビ","ビ");}
    while(s.indexOf("ブ")!=-1){s=s.replace("ブ","ブ");}
    while(s.indexOf("ベ")!=-1){s=s.replace("ベ","ベ");}
    while(s.indexOf("ボ")!=-1){s=s.replace("ボ","ボ");}
  
    while(s.indexOf("パ")!=-1){s=s.replace("パ","パ");}
    while(s.indexOf("ピ")!=-1){s=s.replace("ピ","ピ");}
    while(s.indexOf("プ")!=-1){s=s.replace("プ","プ");}
    while(s.indexOf("ペ")!=-1){s=s.replace("ペ","ペ");}
    while(s.indexOf("ポ")!=-1){s=s.replace("ポ","ポ");}
    obj.value = s;
}

/****************************************************************
* 機 能:  「姓(カナ)」は半角カナチェック
****************************************************************/

var kana = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン ァィゥェォャュョッ、。ー「」゙゚";
var sei_kana = document.getElementById("sei_kana").value;
var textArr = sei_kana.split("");
     for(var i=0;i<textArr.length;i++) {
     var temp = textArr[i];
      // 入力されたのは半角カナ チェック
       if(kana.indexOf(temp) == -1) {
      alert("「姓(カナ)」は半角カナのみを入力してください。");
    document.getElementById("sei_kana").focus();
   //背景色を設定
    document.getElementById("sei_kana").style.backgroundColor  = "#FFFFFF";
   return false;
       }
       }

/****************************************************************
* 機 能:  日期チェック
****************************************************************/


function chkDate(dateStr) {
var regex = /^(\d{4})\-(\d{2})\-(\d{2})$/;
    // 正規表現による書式チェック
    if(!dateStr.match(regex)){
        return false;
    }
  var fstIdx = dateStr.indexOf("-");
    var lstIdx = dateStr.lastIndexOf("-");
   
    var year = dateStr.slice(0,fstIdx);
    var month = dateStr.slice(fstIdx+1,lstIdx);
    var day = dateStr.slice(lstIdx+1);
   
    var maxDay = 0;
    // 特殊な日付をチェックする
    if(year%4 == 0 && month == 2){
    maxDay = 29;
    }
    else if(year%4 != 0 && month == 2){
    maxDay = 28;
    }
    else if(month == 1 || month == 3|| month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    {
    maxDay = 31;
    }
    else {
    maxDay = 30;
    }
    if(day > maxDay){
    return false;
    }
    return true;
}

 
/**************************************************************** 
 * 機 能:mail
 ****************************************************************/ 

function checkMail(value){
	 var flg=value;
	 var mailAdd;
	 if(flg=='1'){
	  mailAdd=$("#mailaddress").val(); 
	 }else{
	  mailAdd=$("#mob_mail_addr").val(); 
	 } 
	
    var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
 	var result = pattern.test(mailAdd);
 	if(result == false){
 	 if(flg=='1'){
 	   $("#mailaddress").attr("value","");
 	   $("#mailaddress").focus();
      }else{
        $("#mob_mail_addr").attr("value","");
         $("#mob_mail_addr").focus();
      }
		return false;
 	  }
 }



package jp.co.asahi_np.biz.bus.common.utility;

import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jp.co.asahi_np.biz.bus.common.log.BULogger;

/**
 * チェックUtilityクラス。
 * @author khou
 *
 */
public final class CheckUtil {

    /**
     * ログクラス宣言。
     */
    private static final BULogger LOGGER = BULogger.getLogger();

    /**
    * コンストラクタ。
    * <p>
    * Utilityクラスのコンストラクタは隠蔽する。
    * </p>
    */
    private CheckUtil() {
    }

    /**
    * 文字列が数値がどうか判定する。
    *
    * @param value
    *            数値判定対象文字列
    * @return true:数値/false:数値以外
    */
    public static boolean isNumber(String value) {
        LOGGER.writeTraceLog("文字列=[" + value + "]");
        boolean result = false;
        try {
            Double.parseDouble(value);
            result = true;
        } catch (Exception e) {
            LOGGER.writeTraceLog("文字列が数値がどうか判定失敗しました:END");
            result = false;
        }
        return result;
    }

    /**
    * 文字列が数値がどうか判定する。(正規表現チェック)。
    *
    * @param value
    *            数値判定対象文字列
    * @return true:数値/false:数値以外
    */
    public static boolean isNumberRx(String value) {
        LOGGER.writeTraceLog("文字列=[" + value + "]");
        String regex = "\\A[-]?[0-9]+\\z";
        Pattern p = Pattern.compile(regex);
        Matcher m1 = p.matcher(value);
        return m1.find();
    }

    /**
    * 文字列がNullもしくは空文字であるかを判定するメソッド。
    *
    * @param target
    *            判定対象となる文字列
    * @return 文字列がNullか空文字であった場合はtrue、それ以外の場合はfalse
    */
    public static boolean isNullOrEmpty(String target) {
        LOGGER.writeTraceLog("Nullもしくは空文字の判定対象文字列 = [" + target + "]");
        boolean rtn = ((target == null) || (target.isEmpty()));
        return rtn;
    }

    /**
    * 指定された文字が半角スペースかどうかを判別する。 この StringUtil のトリム系メソッドで共通で利用する。
    *
    * @param c
    *            対象文字
    * @return ホワイトスペースであるときに true
    */
    public static boolean isWhitespace(char c) {
        return c == ' ';
    }

    /**
    * 指定された文字が全角または半角スペースかどうかを判別する。 この StringUtil のトリム系メソッドで共通で利用する。
    *
    * @param c
    *            対象文字
    * @return 全角または半角スペースであるときに true
    */
    public static boolean isZenHankakuSpace(char c) {
        return (c == ' ' || c == ' ');
    }

    /**
    * 全て全角。
    *
    * @param str 判定文字列
    * @return 全角の場合true、全角ではない場合false
    */
    public static boolean isFullWidthOnly(String str) {

        LOGGER.writeTraceLog("判定対象=[" + str + "]");

        char[] chars = str.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            try {
                if (String.valueOf(chars[i]).getBytes("UTF-8").length < 2) {

                    LOGGER.writeEndLog("全て全角チェック処理終了");
                    //半角混入
                    return false;
                }
            } catch (UnsupportedEncodingException e) {
                //
            }
        }
        return true;
    }

    /**
    * 全て半角。
    *
    * @param str 判定文字列
    * @return 半角の場合true、半角ではない場合false
    */
    public static boolean isHALFWidthOnly(String str) {
        boolean returnvalue = false;
        LOGGER.writeTraceLog("判定対象=[" + str + "]");

        byte[] bytes;

        try {
            bytes = str.getBytes("UTF-8");

            if (str.length() != bytes.length) {
                // 全角混入
                returnvalue = false;
            } else {
                // 半角のみ
                returnvalue = true;
            }

        } catch (UnsupportedEncodingException e) {
            //
        }
        return returnvalue;
    }

    /**
    * 指定正規表現のみの文字列チェック。
    *
    * @param source 判定文字列
    * @param regex 正規表現
    * @return 正規表現と同じ場合true、異なる場合false
    */
    public static boolean isRegexCheckOnly(String source,
            RegexListForCheck regex) {
        boolean result = false;

        LOGGER.writeTraceLog("判定対象=[" + source + "]");
        try {
            Pattern pattern = Pattern.compile(regex.getRegex());
            Matcher matcher = pattern.matcher(source);
            result = matcher.matches();
        } catch (Exception e) {
            result = false;
        }
        return result;
    }

    /**
    * 指定正規表現と正規表現組み合わせの文字列チェック。
    *
    * @param source 判定文字列
    * @param regex1 正規表現1
    * @param regex2 正規表現2
    * @return 指定正規表現と正規表現が同じ場合true、異なる場合false
    */
    public static boolean isRegexCheckAnd(String source,
            RegexListForCheck regex1, RegexListForCheck regex2) {
        boolean result = false;

        LOGGER.writeTraceLog("判定対象=[" + source + "]");
        try {
            if (source.matches(toMatchRegex(regex1.getRegex()
                    + regex2.getRegex()))) {
                result = true;
            } else {
                result = false;
            }
        } catch (Exception e) {
            result = false;
        }
        return result;
    }

    /**
    * 「指定コードのみ」とマッチングする正規表現を返す。
    *
    * @param regexcodes 指定コード
    * @return 指定コードのみ
    */
    private static String toMatchRegex(String regexcodes) {
        return "^[" + regexcodes + "]+$";
    }

    //	// 「指定コード以外が含まれる」とマッチングする正規表現を返す
    //	private static String toNotMatchRegex(String regexcodes) {
    //		return ".*[^" + regexcodes + "].*";
    //	}

    /**
    * ASCII文字チェック。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isAsciiOnly(String str) {
        return str.matches(RegexListForCheck.MATCH_ASCII_ONLY.getRegex());
    }

    /**
    * 全てひらがな。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isHiraganaOnly(String str) {
        return str.matches(RegexListForCheck.MATCH_HIRAGANA_ONLY.getRegex());
    }

    /**
    * 全てカタカナ。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isKatakanaOnly(String str) {
        return str.matches(RegexListForCheck.MATCH_KATAKANA_ONLY.getRegex());
    }

    /**
    * 全て半角カタカナ。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isHalfKatakanaOnly(String str) {
        return str.matches(RegexListForCheck.MATCH_HALF_KANA_ONLY.getRegex());
    }

    /**
    * 全て全角ASCII文字。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isFullWidthAsciiOnly(String str) {
        return str.matches(RegexListForCheck.MATCH_FULL_ASCII_ONLY.getRegex());
    }

    /**
    * メールアドレス簡易チェック。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isEMailAddress(String str) {
        return str.matches(RegexListForCheck.MATCH_MAIL_ADDRESS.getRegex());
    }

    /**
    * URLチェック。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isURL(String str) {
        return str.matches(RegexListForCheck.MATCH_URL.getRegex());
    }

    /**
    * 郵便番号チェック。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isZipCode(String str) {
        return str.matches(RegexListForCheck.MATCH_ZIPCODE.getRegex());
    }

    /**
    * 電話番号チェック。
    *
    * @param str チェック対象文字列
    * @return はい:true いいえ:false
    */
    public static boolean isCorrectTelNo(String str) {
        return str.matches(RegexListForCheck.MATCH_TELEPHONENUMBER.getRegex());
    }

}
分享到:
评论

相关推荐

    excel实现项目进度管理及单元格有效性check

    结合项目开发实例,利用excel的一些常用功能及公式,实现对项目进度的管理,如发生作业延迟,某些数据会变红;作业完成后,该行变灰等。 此表可以清楚看到开发人员是否按时完成作业,项目的进展情况及输入数据是否...

    cppcheck-2.3-x64-Setup.msi

    Cppcheck是一款开源软件,可免费使用哦,可与常用的C++语言开发工具VS,Eclipse等集成,也可单独使用。除了分析整个C++项目,还可直接对单个C语言文件进行静态分析测试,发现可能会引起运行错误的地方。它是一个轻量...

    SAP模块常用增强总结

    在DEBUG界面,查看f_tab字段,这里面所显示的Smod就是关于这个TCODE所有的增强项目的列表。这些增强都是属于EXIT_XXXXXX_XXX这种形式。 至于如何查看这个增强是属于哪个SMOD,可以自己查阅 MODSAP这个表(SAP ...

    Android代码-Android开发常用整理

    Android开发常用整理(不断扩充中)包含各种工具类、线程池、日志、自定义的控件、程序崩溃捕捉处理、默认的Application配置、常用的Adapter等 注意: &gt; 如果需要使用FragmentTabAdapter,则需要android-support-v4....

    Android 常用六大框架

    可通过注解自定义表名,列名,外键,唯一性约束,NOT NULL约束,CHECK约束等(需要混淆的时候请注解表名和列名); 支持绑定外键,保存实体时外键关联实体自动保存或更新; 自动加载外键关联实体,支持延时加载;...

    如何在先进工艺节点利用Virtuoso Check/Assertion Flow

    该流程可以覆盖电路设计常用check需求,完全不依赖脚本,图形界面让工程师更容易上手,基于瞬态仿真的Dynamic Check相比其他工具更具优势。有效利用Check/Assert flow, 可以帮助避免或及早发现设计中的一些常见问题...

    Java毕设基于知识图谱的疾病知识问答系统源码+项目说明.zip

    | Check | 检查项目 | 3342 | 血常规 | | Drug | 治疗药品 | 1204 | 布洛芬片 | | Food | 食物 | 4854 | 蜂蜜 | | Symptom | 症状 | 6556 | 腹腔积血 | | Total | 总计 | 24802 | 约2.5万实体 | ### 2.实体关系...

    altium designer常用元件集成库(IntLib)文件

    个人最常用的集成库了,平时做项目用到的器件和封装都能在里边找到的! 74ACT573T 双向数据传输 74HC138 138译码器 74HC154 4-16译码器 74HC595 移位寄存器 74HC4052 双通道模拟开关 74HVC32M 双输入或门 74LS32M 双...

    gorootcheck:OSSEC在Go中编写独立的rootcheck(rootkit检测)

    这是一个“业余时间”项目,仅供研究建议。gorootcheck Go中OSSEC编写的独立rootcheck2020-22-05 | v0.8.0-持续存在的问题规则#1一些误报( rootkit_files.txt )和错误仍然存​​在规则3绕过问题规则#6误报(在...

    keyboard-shortcut-search:一组常用的键盘快捷键可帮助您提高工作效率:check_mark_button:

    常用键盘快捷键的集合可帮助提高生产力 :check_mark_button: 这个怎么运作 :sparkles: 第1步:选择一个操作系统(Mac或Windows) 第2步:选择类别 本机-在操作系统生态系统内使用的快捷方式。 浏览器-在Chrome...

    leanengine-nodejs-demos:云引擎 Node.js 常用功能和示例汇总

    LeanEngine Node.js Demos该项目是 Node.js 项目的常用功能和示例仓库。包括了推荐的最佳实践和常用的代码片段,每个文件中都有较为详细的注释,适合云引擎的开发者阅读、参考,也可以将代码片段复制到你的项目中...

    vss如何使用(图解)

    当你要编辑或修改某个文档时,必须对文档实施check out 操作(详见3.3.5修改和编辑文件),VSS将该文档从项目中拷贝出来,放入你的工作文件夹。当你修改完毕并check in 文件之后,VSS又将文件重新拷贝到数据库中以...

    visual source safe 教程

    当你要编辑或修改某个文档时,必须对文档实施check out 操作(详见3.3.5修改和编辑文件),VSS将该文档从项目中拷贝出来,放入你的工作文件夹。当你修改完毕并check in 文件之后,VSS又将文件重新拷贝到数据库中以...

    Visual stdio source safe 教程

    当你要编辑或修改某个文档时,必须对文档实施check out 操作(详见3.3.5修改和编辑文件),VSS将该文档从项目中拷贝出来,放入你的工作文件夹。当你修改完毕并check in 文件之后,VSS又将文件重新拷贝到数据库中以...

    base-cfg:个人的常用 webpack 和 typescript 配置的东西

    个人的常用 webpack 和 typescript 配置的东西 package.json { "scripts": { "build": "webpack", "dev": "webpack-dev-server --development" }, "devDependencies": { "@lyonbot/base-cfg": "^1.0.0" }, ...

    VoiceBroadcastDevice:语音播报器

    gradlew check - 运行所有检查(build包含check) gradlew installDebug - 把 debug apk 安装到当前连接的设备上 gradlew connectedAndroidTest - 在连接的设备上安装并运行测试 gradlew tasks - 显示本项目中可用的...

    基于neo4j制作的医药领域-疾病诊断知识图谱dump文件

    医药领域知识图谱,主要包含实体约4.4万个,其中包括Check,诊断检查项目,3353;Department,医疗科目,54;Disease,疾病,8807;Drug,药品,3828;Food,食物, 4870;Producer,在售药品,17201;Symptom,疾病...

    PL/SQL插件VCS使用说明

    所以想找个解决方法,eclipse大家都用管了,可以连接cvs进行代码同步,check in 或check out,那么用一个插件同样能实现SQL代码的版本管理,那就是: VCS插件+VSS。 VCS插件支持三种版本管理工具,vss是我们常用的...

    em-hrs-ingestor:CVP批量导入项目的摄取组件

    Spring Boot应用程序模板 目的 该模板的目的是加速在HMCTS中创建新的Spring应用程序,并帮助在多个团队中保持相同的标准。... 这些检查包含在gradle的检查任务中(您可以通过执行./gradlew check命令来

    java版商城源码下载-check-work:检查工作

    Shiro为权限授权层,Ehcahe对常用数据进行缓存,Activit为工作流引擎。是JavaEE界的最佳整合。 JeeSite主要定位于企业信息化领域,已内置企业信息化系统的基础功能和高效的代码生成工具, 包括:系统权限组件、数据...

Global site tag (gtag.js) - Google Analytics