项目常用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());
    }

}

你可能感兴趣的:(check)