﻿/*
	2007/03/16

	Basic lib. about String

	Required:
		All UTF-8 page, 
	
	by BlueSky.
*/


/*
	matchしたら1、matchがなかったら0
	漢字の場合 utf-8 用。漢字はそれぞれ文字コードにより変わる。
*/

/* ふりがなチェック */
function KanjiCheck(str) {


	for (i=0; i < str.length; i++) {
		if ( !((str.charAt(i) >= "一") && (str.charAt(i) <= "龠")) && !((str.charAt(i) >= "朗") && (str.charAt(i) <= "鶴")) ) {
			//alert("漢字で入力してください");
			return 0;
		}
		else {
			//alert("ok");
			return 1;
		}
	}
/*
	元のソース。
	なぜか /[^一-龠　\s]+/ で 一 が認識しない。
	
	if( str.match( /[^一-龠　\s]+/ ) ) {

		//alert("漢字のみで入力して下さい。");
		return 0;
	}
	else {

		return 1;
	}
*/
}


function HiraganaCheck(str) {

	if( str.match( /[^ぁ-ん　\s]+/ ) ) {
		//alert("ひらがなのみで入力して下さい。");
		return 0;
	}
	else {
		return 1;
	}
}


function KatakanaCheck(str) {

   if( str.match( /[^ァ-ン　\s]+/ ) ) {
	  //alert("カタカナのみで入力して下さい。");
	  return 0;
   }
   else {
	   return 1;
   }
}


function FuriganaCheck(str) {

   if( str.match( /[^ぁ-んァ-ン　\s]+/ ) ) {
	  //alert("ふりがなは、「ひらがな」・「カタカナ」のみで入力して下さい。");
	  return 0;
   }
   else {
   return 1;
   }
}


/* 半角英文字チェック */
function AlphabetCheck(str) {

   if( str.match( /[^A-Za-z\s.-]+/ ) ) {
	  //alert("英語名は、半角英文字のみで入力して下さい。");
	  return 0;
   }
   else {
   return 1;
   }
}

/* 半角英文字チェック */
function IdCheck(str) {

   if( str.match( /[^A-Za-z0-9]+/ ) ) {
	  //alert("英語名は、半角英文字のみで入力して下さい。");
	  return 0;
   }
   else {
   return 1;
   }
}

/* 半角英文字チェック */
function SubDomainCheck(str) {

   if( str.match( /[^A-Za-z0-9-]+/ ) ) {
	  //alert("英語名は、半角英文字のみで入力して下さい。");
	  return 0;
   }
   else {
   return 1;
   }
}

/* 半角数字チェック */
function NumberCheck(str) {
   if( str.match( /[^0-9]+/ ) ) {
	  //alert("半角数字のみで入力して下さい。");
	  return 0;
   }
   else{
   return 1;
   }
}


function EmailCheck(str) {

	if( str.match( /^([a-z0-9+_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,6}$/ ) ) {
		return 1;
	}
	else {
		//alert("E-mailを正しく入力して下さい。");
		return 0;
	}
}

function URLCheck(str) {

	if( str.match( /((http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&amp;:/~\+#()]*[\w\-\@?^=%&amp;/~\+#]))/ ) ) {
		return 1;
	}
	else {
		//alert("URLを正しく入力して下さい。");
		return 0;
	}
}

function JapanZipCodeCheck(str) {

	if( str.match( /^([0-9]{3})-([0-9]{4})$/ ) ) {
		return 1;
	}
	else {
		//alert("郵便番号を正しく入力して下さい。");
		return 0;
	}
}

			


