//##########################################################
// 数値、文字列関連
// 2000 Presented By Takahiro Miura
//
// 2000.10.16修正 宮崎 慎一(外部スタッフ)
// shkjcom_CutAllSpace()を追加
//
// 2001.05.16修正 福永 温(外部スタッフ)
// shkjcom_MobiTelChk(携帯電話番号チェック)から
// 0xx-xxx-xxxxx形式を削除(エラーとする)
//
// 2002.01.30修正 宮崎 慎一(外部スタッフ)
// shkjcom_LeapYearCheck()を追加
//
// 2002.07.10修正 富永 雄次
// shkjcom_ZenKanaChk()にCharCode追加および削除
// 追加:"ー"(長音:12540)
// 削除:ひらがなの"ヴ"(12436)
//
// 2002.07.22修正 富永 雄次
// shkjcom_DateJpConv()のparseIntに第2引数(10)を追加
// 10進数→10進数の変換に固定
//
//##########################################################
//
// 半角/全角スペースをカット
//(現在は入力チェック障害対応として、半角/全角スペース以外の文字が有れば
//入力文字そのままを返し、無ければ空文字を返します)
//
function shkjcom_CutSpace(strMoji)
{
var intFirstSpacePos = 0; // !=スペース開始位置
var intLastSpacePos = 0; // !=スペース終了位置
var strAscCode = 0; // アスキーコード用ワーク領域
var i; // ループカウント
var strReturnString = ''; // 前後スペースカット後文字列
// 前方のスペースをカウントする。
for(i = 0 ; i < strMoji.length ; i++)
{
strAscCode = strMoji.charCodeAt(i) ;
if (strAscCode != 32 && strAscCode != 12288){
// !=スペースをキーにカウント
intFirstSpacePos = i ;
return strMoji;
break ;
}
}
return "";
// 後方のスペースをカウントする。
for(i = strMoji.length - 1 ; 0 < i ; i--)
{
strAscCode = strMoji.charCodeAt(i) ;
if (strAscCode != 32 && strAscCode != 12288){
// !=スペースをキーにカウント
intLastSpacePos = i ;
break ;
}
}
//未入力、又は1文字の時
if (intFirstSpacePos == 0 && intLastSpacePos == 0){
//その1文字が半角/全角スペースの場合、無視する
strAscCode = strMoji.charCodeAt(i) ;
if (strAscCode != 32 && strAscCode != 12288){
strReturnString += strMoji.charAt(0) ;
}
}else{
// 前スペースから後スペースまでループ
for(i = intFirstSpacePos ; i <= intLastSpacePos ; i++){
strReturnString += strMoji.charAt(i) ;
}
}
return strReturnString ;
}
//
// 半角/全角スペースをカット(両端以外文字中のスペースもカット)
//
function shkjcom_CutAllSpace(strMoji)
{
var strAscCode = 0; // アスキーコード用ワーク領域
var i; // ループカウント
var strReturnString = ''; // スペースカット後文字列
for(i = 0 ; i < strMoji.length ; i++)
{
strAscCode = strMoji.charCodeAt(i) ;
if (strAscCode != 32 && strAscCode != 12288)
{
strReturnString += strMoji.charAt(i) ;
}
}
return strReturnString ;
}
//
// 未入力チェック(未入力時にfalseを返す)
//
function shkjcom_NotInpChk(strMoji)
{
var strMsg1 = strMoji;
if (strMsg1.length == 0){
return false;
}else{
return true;
}
}
//
// 半角数字チェック(半角数字以外があればfalseを返す)
//
function shkjcom_NumChk(strMoji)
{
var i;
var strMsg1 = strMoji;
for(i=0; i 57){
return false;
}
}
return true;
}
// 半角数字チェック小数用(半角数字以外があればfalseを返す、小数点が2つ以上ならfalseを返す)
//
function shkjcom_DeciChk(strMoji)
{
var i;
var dflag = 0;
var strMsg1 = strMoji;
for(i=0; i 57)
{
if (strMsg1.charCodeAt(i) == 46)
{
if(dflag == 1)
{return -1;}
else
{dflag = 1}
}
else
{return -2;}
}
}
return true;
}
// 小数点前後の桁数算出
//
function shkjcom_DeciLenChk(strMoji,intCode)
{
var lenString = 0;
var intLength = 0; //文字数
var intPoint; //小数点位置
var strMsg1 = strMoji;
intPoint = strMoji.indexOf(".",0)
intLength = strMoji.length
if(intCode==1)
{lenString = intPoint}
if(intCode==2)
{lenString = intLength-(intPoint+1)}
return lenString;
}
//
// 全角チェック(半角があればfalseを返す)
//
function shkjcom_ZenChk(strMoji)
{
var i;
var ascChar = '';
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
ascChar = strMsg1.charCodeAt(i);
if (ascChar > 65381 && ascChar < 65440){
//半角カナを認識
return false;
}else{
if (ascChar == 65381 || ascChar == 65380 || ascChar == 65377){
//半角「・」「、」「。」を認識
return false;
}else{
//全角文字を認識
}
}
}else{
//半角文字を認識
return false;
}
}
return true;
}
//
// 半角チェック(全角があればfalseを返す)
//
function shkjcom_HanChk(strMoji)
{
var i;
var ascChar = '';
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
ascChar = strMsg1.charCodeAt(i);
if (ascChar > 65381 && ascChar < 65440){
//半角カナを認識
}else{
if (ascChar == 65381 || ascChar == 65380 || ascChar == 65377){
//半角「・」「、」「。」を認識
}else{
//全角文字を認識
return false;
}
}
}
}
return true;
}
//
// 文字数/バイト数算出
//
function shkjcom_LenChk(strMoji)
{
var i;
var ascChar = '';
var lenString = 0; //文字数
var bytString = 0; //バイト数
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
ascChar = strMsg1.charCodeAt(i);
if (ascChar > 65381 && ascChar < 65440){
//半角カナを認識
lenString += 1;
bytString += 1;
}else{
//全角文字を認識
lenString += 1;
bytString += 2;
}
}else{
ascChar = strMsg1.charCodeAt(i);
if (ascChar > 65381 && ascChar < 65440){
//半角カナを認識
lenString += 1;
bytString += 1;
}else{
//全角文字を認識
lenString += 1;
bytString += 2;
}
}
}
return lenString;
}
//
// 実在日チェック
//
function shkjcom_DateChk(intYear,intMonth,intDay)
{
var dat = new Date(intYear, intMonth - 1, intDay);
if(isNaN(dat)){
return false;
}else if((dat.getMonth() + 1) == Number(intMonth)){
return true;
}else{
return false;
}
}
//
// 実在時間チェック
//
function shkjcom_TimeChk(intTime)
{
var intHours;
var intMinutes;
//引数チェック
if (intTime.length != 4){
return false;
}
if (isNaN(intTime) == true){
return false;
}
//「時」チェック
intHours = intTime.substring(0,2);
if (parseInt(intHours) < 0 || parseInt(intHours) > 23){
return false;
}
//「分」チェック
intMinutes = intTime.substring(2,4);
if (parseInt(intMinutes) < 0 || parseInt(intMinutes) > 59){
return false;
}
return true;
}
//
// 全角カナチェック(以外はfalseを返す)
//
function shkjcom_ZenKanaChk(strMoji){
var i;
var ascChar = '';
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
ascChar = strMsg1.charCodeAt(i);
if (ascChar == 32 || ascChar == 12288 || (ascChar >= 12449 && ascChar <= 12527) || (ascChar >= 12530 && ascChar <= 12532) || ascChar == 12540){
// if (ascChar == 32 || ascChar == 12288 || ascChar == 12436 || (ascChar >= 12449 && ascChar <= 12527) || (ascChar >= 12530 && ascChar <= 12532)){
//全角カナを認識
}else{
// !=全角カナを認識
return false;
}
}else{
//半角文字を認識
return false;
}
}
return true;
}
//
// 全角カナ英数字記号チェック(以外はfalseを返す)
// 記号は -()& のみ認める
function shkjcom_ZenKanaAlpmChk(strMoji){
var i;
var ascChar = '';
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
ascChar = strMsg1.charCodeAt(i);
if (ascChar == 32 || ascChar == 12288 || ascChar == 12436 || (ascChar >= 12449 && ascChar <= 12543)){
//全角カナを認識
}else{
// !=全角カナを認識
if ((ascChar >= 65345 && ascChar <= 65370) || (ascChar >= 65313 && ascChar <= 65338) || (ascChar >= 65296 && ascChar <= 65305)){
//全角英数字を認識
}else{
if (ascChar == 8722 || ascChar == 65293 || ascChar == 65288 || ascChar == 65289 || ascChar == 65286){
//全角記号 -()& を認識
}else{
return false;
}
}
}
}else{
//半角文字を認識
return false;
}
}
return true;
}
// 改行コードカット
//
function shkjcom_CrlfCut(strMoji)
{
var strAscCode = 0; // アスキーコード用ワーク領域
var i; // ループカウント
var strReturnString = ''; // スペースカット後文字列
for(i = 0 ; i < strMoji.length ; i++)
{
strAscCode = strMoji.charCodeAt(i) ;
if (strAscCode != 10 && strAscCode != 13)
{
strReturnString += strMoji.charAt(i) ;
}
}
return strReturnString ;
}
//
// E-MAILチェック(半角英数及び半角@以外はfalseを返す)
// ※英字は小文字のみ
function shkjcom_EMailChk(strMoji)
{
var i;
var strUnicode = '';
var strMsg1 = strMoji;
var intCnt = 0; //@の数
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
return false;
}else{
//半角文字を認識
strUnicode = strMsg1.charCodeAt(i);
if (strUnicode == 34){return false;} //「"」があればエラー
if (strUnicode == 42){return false;} //「*」があればエラー
if (strUnicode == 43){return false;} //「+」があればエラー
if (strUnicode == 44){return false;} //「,」があればエラー
if (strUnicode == 47){return false;} //「/」があればエラー
if (strUnicode == 58){return false;} //「:」があればエラー
if (strUnicode == 59){return false;} //「;」があればエラー
if (strUnicode == 60){return false;} //「<」があればエラー
if (strUnicode == 61){return false;} //「=」があればエラー
if (strUnicode == 62){return false;} //「>」があればエラー
if (strUnicode == 63){return false;} //「?」があればエラー
if (strUnicode == 91){return false;} //「[」があればエラー
if (strUnicode == 92){return false;} //「]」があればエラー
if (strUnicode == 93){return false;} //「]」があればエラー
if (strUnicode == 124){return false;} //「/」があればエラー
if (strUnicode == 64){intCnt += 1;} //「@」の数をカウント
}
}
if (intCnt == 1){
//"@"は一個だけだった
return true;
}else{
return false;
}
}
//
// 電話番号チェック(半角数字及び半角"-"以外はfalseを返す)
//
function shkjcom_TellChk(strMoji){
var i;
var strUnicode = ''; //Unicode
var strChar = ''; //ワーク1文字
var strTellPtn = ''; //電話番号パターン
var strTellNum = ''; //電話番号連番
var strMsg1 = strMoji;
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
return false;
}else{
//半角文字を認識
strChar = strMsg1.charAt(i);
strUnicode = strMsg1.charCodeAt(i);
switch (strUnicode){
case 45: //半角ハイフン
strTellPtn += strChar;
break;
case 48: //半角数字「0」
if (i == 0){
strTellPtn += strChar;
}else{
strTellPtn += "x";
}
strTellNum += strChar;
break;
case 49: //半角数字「1」
case 50: //半角数字「2」
case 51: //半角数字「3」
case 52: //半角数字「4」
case 53: //半角数字「5」
case 54: //半角数字「6」
case 55: //半角数字「7」
case 56: //半角数字「8」
case 57: //半角数字「9」
strTellPtn += "x";
strTellNum += strChar;
break;
default:
return false;
break;
}
}
}
if (strTellPtn.length < 4){
return false;
}
//電話番号チェック
if (strTellNum.slice(0,3) == "100"){return false;}
if (strTellNum.slice(0,3) == "104"){return false;}
if (strTellNum.slice(0,3) == "106"){return false;}
if (strTellNum.slice(0,3) == "110"){return false;}
if (strTellNum.slice(0,3) == "113"){return false;}
if (strTellNum.slice(0,3) == "114"){return false;}
if (strTellNum.slice(0,3) == "115"){return false;}
if (strTellNum.slice(0,3) == "116"){return false;}
if (strTellNum.slice(0,3) == "117"){return false;}
if (strTellNum.slice(0,3) == "119"){return false;}
if (strTellNum.slice(0,3) == "177"){return false;}
if (strTellNum.slice(0,4) == "0990"){return false;}
//電話番号パターンチェック
// if (strTellPtn == "x-xxxx") {return true;}
// if (strTellPtn == "xx-xxxx") {return true;}
if (strTellPtn == "0x-xxx-xxxx") {return true;}
if (strTellPtn == "0xx-xx-xxxx") {return true;}
if (strTellPtn == "0xxx-x-xxxx") {return true;}
if (strTellPtn == "0xxxxx-xxxx") {return true;}
if (strTellPtn == "0x-xxxx-xxxx") {return true;}
if (strTellPtn == "0xx-xxx-xxxx") {return true;}
if (strTellPtn == "0xxx-xx-xxxx") {return true;}
if (strTellPtn == "0xxxx-x-xxxx") {return true;}
if (strTellPtn == "0xx-xx-xxxxx") {return true;}
return false;
}
//
// 携帯電話番号チェック(半角数字及び半角"-"以外はfalseを返す)
//
function shkjcom_MobiTelChk(strTelephoneNumber){
var i;
var strUnicode = ''; //Unicode
var strChar = ''; //ワーク1文字
var strTelPtn = ''; //電話番号パターン
var strTelNum = ''; //電話番号連番
for(i=0; i 3){
//全角文字(IEのみ半角カナ含む)を認識
return false;
}else{
//半角文字を認識
strChar = strTelephoneNumber.charAt(i);
strUnicode = strTelephoneNumber.charCodeAt(i);
switch (strUnicode){
case 45: //半角ハイフン
strTelPtn += strChar;
break;
case 48: //半角数字「0」
if (i == 0){
strTelPtn += strChar;
}else{
strTelPtn += "x";
}
strTelNum += strChar;
break;
case 49: //半角数字「1」
case 50: //半角数字「2」
case 51: //半角数字「3」
case 52: //半角数字「4」
case 53: //半角数字「5」
case 54: //半角数字「6」
case 55: //半角数字「7」
case 56: //半角数字「8」
case 57: //半角数字「9」
strTelPtn += "x";
strTelNum += strChar;
break;
default:
return false;
break;
}
}
}
if (strTelPtn.length < 4){
return false;
}
//電話番号チェック
if (strTelNum.slice(0,3) == "100"){return false;}
if (strTelNum.slice(0,3) == "104"){return false;}
if (strTelNum.slice(0,3) == "106"){return false;}
if (strTelNum.slice(0,3) == "110"){return false;}
if (strTelNum.slice(0,3) == "113"){return false;}
if (strTelNum.slice(0,3) == "114"){return false;}
if (strTelNum.slice(0,3) == "115"){return false;}
if (strTelNum.slice(0,3) == "116"){return false;}
if (strTelNum.slice(0,3) == "117"){return false;}
if (strTelNum.slice(0,3) == "119"){return false;}
if (strTelNum.slice(0,3) == "177"){return false;}
if (strTelNum.slice(0,4) == "0990"){return false;}
//電話番号パターンチェック
if (strTelPtn == "0xxxxxxxxxx") {return true;}
if (strTelPtn == "0xx-xxxx-xxxx") {return true;}
return false;
}
//
// 和暦→西暦変換
//
function shkjcom_DateJpConv(strJpYaer,intYear,intMonth,intDay)
{
var dat;
var strMonthDay = "";
var year = 0;
var month = 0;
var day = 0;
//引数チェック
// 2002.07.22 GECC富永 変更 ( EC-782 )
if(parseInt(intYear, 10) < 1 || parseInt(intYear, 10) > 99 || isNaN(intYear) == true || intYear == "" || intYear == " "){
// if (parseInt(intYear) < 1 || parseInt(intYear) > 99 || isNaN(intYear) == true || intYear == "" || intYear == " "){
return false;
}
// 2002.07.22 GECC富永 変更 ( EC-782 )
if(parseInt(intMonth, 10) < 1 || parseInt(intMonth, 10) > 12 || isNaN(intMonth) == true || intMonth == "" || intMonth == " "){
// if (parseInt(intMonth) < 1 || parseInt(intMonth) > 12 || isNaN(intMonth) == true || intMonth == "" || intMonth == " "){
return false;
}
// 2002.07.22 GECC富永 変更 ( EC-782 )
if(parseInt(intDay, 10) < 1 || parseInt(intDay) > 31 || isNaN(intDay) == true || intDay == "" || intDay == " "){
// if (parseInt(intDay) < 1 || parseInt(intDay) > 31 || isNaN(intDay) == true || intDay == "" || intDay == " "){
return false;
}
// 2002.07.22 GECC富永 変更 ( EC-782 )
strMonthDay = "" + parseInt(intMonth, 10) + parseInt(intDay, 10);
// strMonthDay = "" + parseInt(intMonth) + parseInt(intDay);
switch (strJpYaer){
case "平成":
// 2002.07.22 GECC富永 変更 ( EC-782 )
if((parseInt(intYear, 10) == 1 && parseInt(strMonthDay, 10) < 18) || parseInt(intYear, 10) < 1){
// if ((parseInt(intYear) == 1 && parseInt(strMonthDay) < 18) || parseInt(intYear) < 1){
return false;
}else{
// 2002.07.22 GECC富永 変更 ( EC-782 )
year = parseInt(intYear, 10) + 1988;
// year = parseInt(intYear) + 1988;
}
break;
case "昭和":
// 2002.07.22 GECC富永 変更 ( EC-782 )
if((parseInt(intYear, 10) == 1 && parseInt(strMonthDay, 10) < 1225) || (parseInt(intYear, 10) == 64 && parseInt(strMonthDay, 10) > 17) || (parseInt(intYear, 10) < 1 || parseInt(intYear, 10) > 64)){
// if ((parseInt(intYear) == 1 && parseInt(strMonthDay) < 1225) || (parseInt(intYear) == 64 && parseInt(strMonthDay) > 17) || (parseInt(intYear) < 1 || parseInt(intYear) > 64)){
return false;
}else{
// 2002.07.22 GECC富永 変更 ( EC-782 )
year = parseInt(intYear, 10) + 1925;
// year = parseInt(intYear) + 1925;
}
break;
case "大正":
// 2002.07.22 GECC富永 変更 ( EC-782 )
if((parseInt(intYear, 10) == 1 && parseInt(strMonthDay, 10) < 730) || (parseInt(intYear, 10) == 15 && parseInt(strMonthDay, 10) > 1224) || (parseInt(intYear, 10) < 1 || parseInt(intYear, 10) > 15)){
// if ((parseInt(intYear) == 1 && parseInt(strMonthDay) < 730) || (parseInt(intYear) == 15 && parseInt(strMonthDay) > 1224) || (parseInt(intYear) < 1 || parseInt(intYear) > 15)){
return false;
}else{
// 2002.07.22 GECC富永 変更 ( EC-782 )
year = parseInt(intYear, 10) + 1911;
// year = parseInt(intYear) + 1911;
}
break;
case "明治":
// 2002.07.22 GECC富永 変更 ( EC-782 )
if((parseInt(intYear, 10) == 1 && parseInt(strMonthDay, 10) < 98) || (parseInt(intYear) == 45 && parseInt(strMonthDay) > 729) || (parseInt(intYear, 10) < 1 || parseInt(intYear, 10) > 45)){
// if ((parseInt(intYear) == 1 && parseInt(strMonthDay) < 98) || (parseInt(intYear) == 45 && parseInt(strMonthDay) > 729) || (parseInt(intYear) < 1 || parseInt(intYear) > 45)){
return false;
}else{
// 2002.07.22 GECC富永 変更 ( EC-782 )
year = parseInt(intYear, 10) + 1867;
// year = parseInt(intYear) + 1867;
}
break;
default:
return false;
break;
}
dat = new Date(year, intMonth - 1, intDay);
if (intMonth == dat.getMonth() + 1){
if (intMonth.length == 1){
month = "0" + intMonth
}else{
month = intMonth
}
if (intDay.length == 1){
day = "0" + intDay
}else{
day = intDay
}
return year + month + day;
}else{
return false;
}
}
//
// クライアントのシステム日付取得
// ※クライアントのシステム日付の為、正確な日付とは限らない
function shkjcom_GetSystemDate(intType)
{
var strYear;
var strMonth;
var strDay;
var objDate;
var dtmReturn;
//日付オブジェクト作成
objDate = new Date();
strYear = '' + objDate.getFullYear();
strMonth = objDate.getMonth()+1;
//頭ゼロ埋め処理(月)
if (strMonth >= 1 && strMonth <= 9){
strMonth = '0' + strMonth
}
strDay = objDate.getDate();
//頭ゼロ埋め処理(日)
if (strDay >= 1 && strDay <= 9){
strDay = '0' + strDay
}
switch (parseInt(intType)){
case 1: //6桁スラッシュ有り
strYear = '' + strYear.slice(2,4);
dtmReturn = strYear + '/' + strMonth + '/' + strDay;
break;
case 2: //6桁スラッシュ無し
strYear = '' + strYear.slice(2,4);
dtmReturn = strYear + '' + strMonth + '' + strDay;
break;
case 3: //8桁スラッシュ有り
dtmReturn = strYear + '/' + strMonth + '/' + strDay;
break;
case 4: //8桁スラッシュ無し
dtmReturn = strYear + '' + strMonth + '' + strDay;
break;
default:
return false;
break;
}
return dtmReturn;
}
//
// クライアントのシステム時刻取得
// ※クライアントのシステム時刻の為、正確な時刻とは限らない
function shkjcom_GetSystemTime(intType)
{
var strHour;
var strMinute;
var strSecond;
var objDate;
var dtmReturn;
//日付オブジェクト作成
objDate = new Date();
strHour = objDate.getHours();
//頭ゼロ埋め処理(時)
if (strHour >= 0 && strHour <= 9){
strHour = '0' + strHour
}
strMinute = objDate.getMinutes();
//頭ゼロ埋め処理(分)
if (strMinute >= 0 && strMinute <= 9){
strMinute = '0' + strMinute
}
strSecond = objDate.getSeconds();
//頭ゼロ埋め処理(秒)
if (strSecond >= 0 && strSecond <= 9){
strSecond = '0' + strSecond
}
switch (parseInt(intType)){
case 1: //コロン有り
dtmReturn = strHour + ':' + strMinute + ':' + strSecond;
break;
case 2: //コロン無し
dtmReturn = strHour + '' + strMinute + '' + strSecond;
break;
default:
return false;
break;
}
return dtmReturn;
}
//
// NetScapeのバージョンが4.06/4.5以降かチェックする
//
function shkjcom_ChkBrowser(){
var strMoji = "漢";
if (strMoji.length != 1){
location="/error1.html";
}
}
//
//うるう年のチェックを行う。
//
function shkjcom_LeapYearCheck()
{
var strYear;
var objDate;
//日付オブジェクト作成
objDate = new Date();
strYear = objDate.getFullYear();
if (strYear%400==0)
{
return 1;
}
if (strYear%100==0)
{
return 2;
}
if (strYear%4==0)
{
return 1;
}
else
{
return 2;
}
}
//
//うるう年のチェックを行う。
//
function shkjcom_LeapYearCheck_2(strYear)
{
if (strYear%400==0)
{
return 1;
}
if (strYear%100==0)
{
return 2;
}
if (strYear%4==0)
{
return 1;
}
else
{
return 2;
}
}