<!--
//日入力後日の数値チェック及び日付が正しいかをチェック：エラー無しなら年齢計算開始
function myAge(N){
var strValue = document.mailform.myAgeD.value;
var strValueY = document.mailform.myAgeY.value;
var strValueM = document.mailform.myAgeM.value;
if (!chkDigit(strValue)) {
//alert("数値以外が含まれてます");
document.mailform.myAgeM.value = "";
document.mailform.myAgeM.focus();
return;
} else if (strValueY == "" || strValueM == "" || strValue == "") {
//alert("未入力項目があります");
if (strValueY == "") {
document.mailform.myAgeY.focus();
} else if (strValueM == "") {
document.mailform.myAgeM.focus();
} else {
document.mailform.myAgeD.focus();
}
return;
} else if (strValue < 0 || strValue > 31) {
//alert("不正な日付が入力されています");
document.mailform.myAgeD.value = "";
document.mailform.myAgeD.focus();
return;
} else {
var uru = chkUru(strValueY);
if (uru) {
if (strValueM == 2 && strValue > 29) {
//alert("不正な日付が入力されています");
document.mailform.myAgeD.value = "";
document.mailform.myAgeD.focus();
return;
}
} else {
if (strValueM == 2 && strValue > 28) {
//alert("不正な日付が入力されています");
document.mailform.myAgeD.value = "";
document.mailform.myAgeD.focus();
return;
}
}
if ((strValueM == 4 || strValueM == 6 || strValueM == 9 || strValueM == 11) && strValue > 30) {
document.mailform.myAgeD.value = "";
//alert("不正な日付が入力されています");
document.mailform.myAgeD.focus();
return;
}
}
//現在から、誕生日を引き、基準日に足す
//つまり、現在から、誕生日の日にち分の時間だけ引く
Today = new Date();
myBirth = new Date(1970 ,
0 ,
document.mailform.myAgeD.value );

myBirth.setTime(Today.getTime()-myBirth.getTime());


//求めた年月日から基準日を引く
myYear = myBirth.getUTCFullYear() - document.mailform.myAgeY.value;
myMonth = myBirth.getUTCMonth() - (document.mailform.myAgeM.value - 1);
if(myMonth < 0){
//月がマイナスなので年から繰り下げ
myYear --;
myMonth += 12;
}

myDate = myBirth.getUTCDate();

document.mailform.Age.value = ""+myYear+"";
}
//年入力後のチェック
function checky() {
var strValue = document.mailform.myAgeY.value;
if (!chkDigit(strValue)) {
//alert("数値以外が含まれてます");
document.mailform.myAgeY.value = "";
document.mailform.myAgeY.focus();
return;
}
}
//月入力後のチェック
function checkm() {
var strValue = document.mailform.myAgeM.value;

if (!chkDigit(strValue)) {
//alert("数値以外が含まれてます");
document.mailform.myAgeM.value = "";
document.mailform.myAgeM.focus();
return;
}
if (strValue < 0 || strValue > 12) {
//alert("正しい月を入力してください");
document.mailform.myAgeM.value = "";
document.mailform.myAgeM.focus();
return;
}
}
//数字判定：数字のみならtrueを返す
function chkDigit(txt) {
for (i=0; i<txt.length; i++) {
c = txt.charAt(i);
if ("0123456789".indexOf(c,0) < 0) {
return false;
}
}
return true;
}
//閏年チェック
function chkUru(y) {
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
if (flag) {
return true;
} else {
return false;
}
}
}
//-->

