2015年5月31日日曜日

JavaScriptサンプル


//=============================
//check Header
//=============================
var flagHeader =
{
txtYear:false,
txtMonth:false,
txtTantou: false,
    txtSyamei:false,
    txtYearRep0:false,
    txtMonthRep0: false
 
};



function headerIsMust()
{

    //必須チェック
    if (isEmpty("txtYear")) {
        flagHeader.txtYear = true;
    }
    else {
        flagHeader.txtYear = false;
    }

    if (isEmpty("txtMonth")) {
        flagHeader.txtMonth = true;

    } else {
        flagHeader.txtMonth = false;

    }

    if (isEmpty("txtDay")) {
        flagHeader.txtDay = true;
    } else {
        flagHeader.txtDay = false;

    }

    if (isEmpty("txtSyamei")) {
        flagHeader.txtSyamei = true;
    } else {
        flagHeader.txtSyamei = false;

    }

    if (isEmpty("txtTantou")) {
        flagHeader.txtTantou = true;
    } else {
        flagHeader.txtTantou = false;
    }

    if (isEmpty("txtYearRep0")) {
        flagHeader.txtYearRep0 = true;
    } else {
        flagHeader.txtYearRep0 = false;

    }

    if (isEmpty("txtMonthRep0")) {
        flagHeader.txtMonthRep0 = true;
    } else {
        flagHeader.txtMonthRep0 = false;

    }

    if (   flagHeader.txtYear     && flagHeader.txtMonth && flagHeader.txtDay
        && flagHeader.txtSyamei   && flagHeader.txtTantou
        && flagHeader.txtYearRep0 && flagHeader.txtMonthRep0
            ) {
   
    } else {
        return false;
    }

    return true;
}

function headerNumberIsValid() {
    //数字チェック  
    if (isNumber("txtYear")) {
        flagHeader.txtYear = true;
    } else {
        flagHeader.txtYear = false;
    }

    if (isNumber("txtMonth")) {
        flagHeader.txtMonth = true;
    } else {
        flagHeader.txtMonth = false;
    }

    if (isNumber("txtDay")) {
        flagHeader.txtDay = true;
    } else {
        flagHeader.txtDay = false;
    }

    if (isNumber("txtYearRep0")) {
        flagHeader.txtYearRep0 = true;
    } else {
        flagHeader.txtYearRep0 = false;
    }

    if (isNumber("txtMonthRep0")) {
        flagHeader.txtMonthRep0 = true;
    } else {
        flagHeader.txtMonthRep0 = false;
    }
 
    if (flagHeader.txtYear && flagHeader.txtMonth && flagHeader.txtDay
        && flagHeader.txtYearRep0 && flagHeader.txtMonthRep0
        ) {
 
    } else {
        return false;
    }

    return true;

}


function headerMonthRangeIsValid() {

    //月
    if (document.getElementById("txtMonthRep0").value * 1 > 12 || document.getElementById("txtMonthRep0").value * 1 < 1) {
        flagHeader.txtMonthRep0 = false;

    }
    else {
        flagHeader.txtMonthRep0 = true;
    }


    if (flagHeader.txtMonthRep0) {

    } else {
        return false;
    }

    return true;
}


function checkFormsHeader() {

    //必須チェック
    if (!headerIsMust()) {
        return false;
    }

    //数字チェック
    if (!headerNumberIsValid()) {
        return false;
    }

    //範囲チェック
    if (!headerMonthRangeIsValid()) {
        return false;
    }

}

//=============================
//check Mito
//=============================
var flgMito =
{
txtMito_Kamotu1:false,
txtMito_Kamotu2:false,
txtMito_Kamotu3:false,
txtMito_Kamotu4:false,
txtMito_Bus1:false,
txtMito_Bus2:false,
txtMito_JK_J1:false,
txtMito_JK_K1:false,
txtMito_JK_J2:false,
txtMito_JK_K2:false,
txtMito_JK_J3:false,
txtMito_JK_K3:false,
txtMito_SubTotal1:false,
txtMito_Total1:false
};

function checkMito(){
if (isNumber("txtMito_Kamotu1")) {
flgMito.txtMito_Kamotu1 = true;
}else{
flgMito.txtMito_Kamotu1 = false;
}
if (isNumber("txtMito_Kamotu2")) {
flgMito.txtMito_Kamotu2 = true;
    } else {
flgMito.txtMito_Kamotu2 = false;
    }
    if (isNumber("txtMito_Kamotu3")) {
flgMito.txtMito_Kamotu3 = true;
    } else {
flgMito.txtMito_Kamotu3 = false;
    }
if (isNumber("txtMito_Kamotu4")) {
flgMito.txtMito_Kamotu4 = true;
    } else {
flgMito.txtMito_Kamotu4 = false;
    }    
  if (isNumber("txtMito_Bus1")) {
flgMito.txtMito_Bus1 = true;
    } else {
flgMito.txtMito_Bus1 = false;
    }
  if (isNumber("txtMito_Bus2")) {
flgMito.txtMito_Bus2 = true;
    } else {
flgMito.txtMito_Bus2 = false;
    }
if (isNumber("txtMito_JK_J1")) {
flgMito.txtMito_JK_J1 = true;
    } else {
flgMito.txtMito_JK_J1 = false;
    }

if (isNumber("txtMito_JK_K1")) {
flgMito.txtMito_JK_K1 = true;
    } else {
flgMito.txtMito_JK_K1 = false;

    }
if (isNumber("txtMito_JK_J2")) {
flgMito.txtMito_JK_J2 = true;
    } else {
flgMito.txtMito_JK_J2 = false;
    }

if (isNumber("txtMito_JK_K2")) {
flgMito.txtMito_JK_K2 = true;
    } else {
flgMito.txtMito_JK_K2 = false;
    }
         
    if (isNumber("txtMito_JK_J3")) {
flgMito.txtMito_JK_J3 = true;
    } else {
flgMito.txtMito_JK_J3 = false;
    }
 
if (isNumber("txtMito_JK_K3")) {
flgMito.txtMito_JK_K3 = true;
    } else {
flgMito.txtMito_JK_K3 = false;
    }

if (isNumber("txtMito_SubTotal1")) {
flgMito.txtMito_SubTotal1 = true;
    } else {
flgMito.txtMito_SubTotal1 = false;
    }

if (isNumber("txtMito_Total1")) {
flgMito.txtMito_Total1 = true;
    } else {
flgMito.txtMito_Total1 = false;
    }

if(flgMito.txtMito_Kamotu1 && flgMito.txtMito_Kamotu2 && flgMito.txtMito_Kamotu3 &&
flgMito.txtMito_Kamotu4 && flgMito.txtMito_Bus1   && flgMito.txtMito_Bus2  &&
flgMito.txtMito_JK_J1 && flgMito.txtMito_JK_K1 && flgMito.txtMito_JK_J2 &&
flgMito.txtMito_JK_K2 && flgMito.txtMito_JK_J3 && flgMito.txtMito_JK_K3 &&
flgMito.txtMito_SubTotal1  && flgMito.txtMito_Total1)
{
return true;

}else{
return false;
}

}

//=============================
//check Tuchiura
//=============================
var flgTuchiura =
{
txtTuchiura_Kamotu1:false,
txtTuchiura_Kamotu2:false,
txtTuchiura_Kamotu3:false,
txtTuchiura_Kamotu4:false,
txtTuchiura_Bus1:false,
txtTuchiura_Bus2:false,
txtTuchiura_JK_J1:false,
txtTuchiura_JK_K1:false,
txtTuchiura_JK_J2:false,
txtTuchiura_JK_K2:false,
txtTuchiura_JK_J3:false,
txtTuchiura_JK_K3:false,
txtTuchiura_SubTotal1:false,
txtTuchiura_Total1:false
};

function checkTuchiura(){
if (isNumber("txtTuchiura_Kamotu1")) {
flgTuchiura.txtTuchiura_Kamotu1 = true;
}else{
flgTuchiura.txtTuchiura_Kamotu1 = false;
}
if (isNumber("txtTuchiura_Kamotu2")) {
flgTuchiura.txtTuchiura_Kamotu2 = true;
    } else {
flgTuchiura.txtTuchiura_Kamotu2 = false;
    }
    if (isNumber("txtTuchiura_Kamotu3")) {
flgTuchiura.txtTuchiura_Kamotu3 = true;
    } else {
flgTuchiura.txtTuchiura_Kamotu3 = false;
    }
if (isNumber("txtTuchiura_Kamotu4")) {
flgTuchiura.txtTuchiura_Kamotu4 = true;
    } else {
flgTuchiura.txtTuchiura_Kamotu4 = false;
    }    
  if (isNumber("txtTuchiura_Bus1")) {
flgTuchiura.txtTuchiura_Bus1 = true;
    } else {
flgTuchiura.txtTuchiura_Bus1 = false;
    }
  if (isNumber("txtTuchiura_Bus2")) {
flgTuchiura.txtTuchiura_Bus2 = true;
    } else {
flgTuchiura.txtTuchiura_Bus2 = false;
    }
if (isNumber("txtTuchiura_JK_J1")) {
flgTuchiura.txtTuchiura_JK_J1 = true;
    } else {
flgTuchiura.txtTuchiura_JK_J1 = false;
    }

if (isNumber("txtTuchiura_JK_K1")) {
flgTuchiura.txtTuchiura_JK_K1 = true;
    } else {
flgTuchiura.txtTuchiura_JK_K1 = false;

    }
if (isNumber("txtTuchiura_JK_J2")) {
flgTuchiura.txtTuchiura_JK_J2 = true;
    } else {
flgTuchiura.txtTuchiura_JK_J2 = false;
    }

if (isNumber("txtTuchiura_JK_K2")) {
flgTuchiura.txtTuchiura_JK_K2 = true;
    } else {
flgTuchiura.txtTuchiura_JK_K2 = false;
    }
         
    if (isNumber("txtTuchiura_JK_J3")) {
flgTuchiura.txtTuchiura_JK_J3 = true;
    } else {
flgTuchiura.txtTuchiura_JK_J3 = false;
    }
 
if (isNumber("txtTuchiura_JK_K3")) {
flgTuchiura.txtTuchiura_JK_K3 = true;
    } else {
flgTuchiura.txtTuchiura_JK_K3 = false;
    }

if (isNumber("txtTuchiura_SubTotal1")) {
flgTuchiura.txtTuchiura_SubTotal1 = true;
    } else {
flgTuchiura.txtTuchiura_SubTotal1 = false;
    }

if (isNumber("txtTuchiura_Total1")) {
flgTuchiura.txtTuchiura_Total1 = true;
    } else {
flgTuchiura.txtTuchiura_Total1 = false;
    }

if(flgTuchiura.txtTuchiura_Kamotu1 && flgTuchiura.txtTuchiura_Kamotu2 && flgTuchiura.txtTuchiura_Kamotu3 &&
flgTuchiura.txtTuchiura_Kamotu4 && flgTuchiura.txtTuchiura_Bus1   && flgTuchiura.txtTuchiura_Bus2  &&
flgTuchiura.txtTuchiura_JK_J1 && flgTuchiura.txtTuchiura_JK_K1 && flgTuchiura.txtTuchiura_JK_J2 &&
flgTuchiura.txtTuchiura_JK_K2 && flgTuchiura.txtTuchiura_JK_J3 && flgTuchiura.txtTuchiura_JK_K3 &&
flgTuchiura.txtTuchiura_SubTotal1  && flgTuchiura.txtTuchiura_Total1)
{
return true;

}else{
return false;
}

}

//=============================
//check Tukuba
//=============================
var flgTukuba =
{
txtTukuba_Kamotu1:false,
txtTukuba_Kamotu2:false,
txtTukuba_Kamotu3:false,
txtTukuba_Kamotu4:false,
txtTukuba_Bus1:false,
txtTukuba_Bus2:false,
txtTukuba_JK_J1:false,
txtTukuba_JK_K1:false,
txtTukuba_JK_J2:false,
txtTukuba_JK_K2:false,
txtTukuba_JK_J3:false,
txtTukuba_JK_K3:false,
txtTukuba_SubTotal1:false,
txtTukuba_Total1:false
};

function checkTukuba(){
if (isNumber("txtTukuba_Kamotu1")) {
flgTukuba.txtTukuba_Kamotu1 = true;
}else{
flgTukuba.txtTukuba_Kamotu1 = false;
}
if (isNumber("txtTukuba_Kamotu2")) {
flgTukuba.txtTukuba_Kamotu2 = true;
    } else {
flgTukuba.txtTukuba_Kamotu2 = false;
    }
    if (isNumber("txtTukuba_Kamotu3")) {
flgTukuba.txtTukuba_Kamotu3 = true;
    } else {
flgTukuba.txtTukuba_Kamotu3 = false;
    }
if (isNumber("txtTukuba_Kamotu4")) {
flgTukuba.txtTukuba_Kamotu4 = true;
    } else {
flgTukuba.txtTukuba_Kamotu4 = false;
    }    
  if (isNumber("txtTukuba_Bus1")) {
flgTukuba.txtTukuba_Bus1 = true;
    } else {
flgTukuba.txtTukuba_Bus1 = false;
    }
  if (isNumber("txtTukuba_Bus2")) {
flgTukuba.txtTukuba_Bus2 = true;
    } else {
flgTukuba.txtTukuba_Bus2 = false;
    }
if (isNumber("txtTukuba_JK_J1")) {
flgTukuba.txtTukuba_JK_J1 = true;
    } else {
flgTukuba.txtTukuba_JK_J1 = false;
    }

if (isNumber("txtTukuba_JK_K1")) {
flgTukuba.txtTukuba_JK_K1 = true;
    } else {
flgTukuba.txtTukuba_JK_K1 = false;

    }
if (isNumber("txtTukuba_JK_J2")) {
flgTukuba.txtTukuba_JK_J2 = true;
    } else {
flgTukuba.txtTukuba_JK_J2 = false;
    }

if (isNumber("txtTukuba_JK_K2")) {
flgTukuba.txtTukuba_JK_K2 = true;
    } else {
flgTukuba.txtTukuba_JK_K2 = false;
    }
         
    if (isNumber("txtTukuba_JK_J3")) {
flgTukuba.txtTukuba_JK_J3 = true;
    } else {
flgTukuba.txtTukuba_JK_J3 = false;
    }
 
if (isNumber("txtTukuba_JK_K3")) {
flgTukuba.txtTukuba_JK_K3 = true;
    } else {
flgTukuba.txtTukuba_JK_K3 = false;
    }

if (isNumber("txtTukuba_SubTotal1")) {
flgTukuba.txtTukuba_SubTotal1 = true;
    } else {
flgTukuba.txtTukuba_SubTotal1 = false;
    }

if (isNumber("txtTukuba_Total1")) {
flgTukuba.txtTukuba_Total1 = true;
    } else {
flgTukuba.txtTukuba_Total1 = false;
    }

if(flgTukuba.txtTukuba_Kamotu1 && flgTukuba.txtTukuba_Kamotu2 && flgTukuba.txtTukuba_Kamotu3 &&
flgTukuba.txtTukuba_Kamotu4 && flgTukuba.txtTukuba_Bus1   && flgTukuba.txtTukuba_Bus2  &&
flgTukuba.txtTukuba_JK_J1 && flgTukuba.txtTukuba_JK_K1 && flgTukuba.txtTukuba_JK_J2 &&
flgTukuba.txtTukuba_JK_K2 && flgTukuba.txtTukuba_JK_J3 && flgTukuba.txtTukuba_JK_K3 &&
flgTukuba.txtTukuba_SubTotal1  && flgTukuba.txtTukuba_Total1)
{
return true;

}else{
return false;
}

}


//=============================
//check Sonota
//=============================
var flgSonota =
{
txtSonota_Kamotu1:false,
txtSonota_Kamotu2:false,
txtSonota_Kamotu3:false,
txtSonota_Kamotu4:false,
txtSonota_Bus1:false,
txtSonota_Bus2:false,
txtSonota_JK_J1:false,
txtSonota_JK_K1:false,
txtSonota_JK_J2:false,
txtSonota_JK_K2:false,
txtSonota_JK_J3:false,
txtSonota_JK_K3:false,
txtSonota_SubTotal1:false,
txtSonota_Total1:false
};

function checkSonota(){
if (isNumber("txtSonota_Kamotu1")) {
flgSonota.txtSonota_Kamotu1 = true;
}else{
flgSonota.txtSonota_Kamotu1 = false;
}
if (isNumber("txtSonota_Kamotu2")) {
flgSonota.txtSonota_Kamotu2 = true;
    } else {
flgSonota.txtSonota_Kamotu2 = false;
    }
    if (isNumber("txtSonota_Kamotu3")) {
flgSonota.txtSonota_Kamotu3 = true;
    } else {
flgSonota.txtSonota_Kamotu3 = false;
    }
if (isNumber("txtSonota_Kamotu4")) {
flgSonota.txtSonota_Kamotu4 = true;
    } else {
flgSonota.txtSonota_Kamotu4 = false;
    }    
  if (isNumber("txtSonota_Bus1")) {
flgSonota.txtSonota_Bus1 = true;
    } else {
flgSonota.txtSonota_Bus1 = false;
    }
  if (isNumber("txtSonota_Bus2")) {
flgSonota.txtSonota_Bus2 = true;
    } else {
flgSonota.txtSonota_Bus2 = false;
    }
if (isNumber("txtSonota_JK_J1")) {
flgSonota.txtSonota_JK_J1 = true;
    } else {
flgSonota.txtSonota_JK_J1 = false;
    }

if (isNumber("txtSonota_JK_K1")) {
flgSonota.txtSonota_JK_K1 = true;
    } else {
flgSonota.txtSonota_JK_K1 = false;

    }
if (isNumber("txtSonota_JK_J2")) {
flgSonota.txtSonota_JK_J2 = true;
    } else {
flgSonota.txtSonota_JK_J2 = false;
    }

if (isNumber("txtSonota_JK_K2")) {
flgSonota.txtSonota_JK_K2 = true;
    } else {
flgSonota.txtSonota_JK_K2 = false;
    }
         
    if (isNumber("txtSonota_JK_J3")) {
flgSonota.txtSonota_JK_J3 = true;
    } else {
flgSonota.txtSonota_JK_J3 = false;
    }
 
if (isNumber("txtSonota_JK_K3")) {
flgSonota.txtSonota_JK_K3 = true;
    } else {
flgSonota.txtSonota_JK_K3 = false;
    }

if (isNumber("txtSonota_SubTotal1")) {
flgSonota.txtSonota_SubTotal1 = true;
    } else {
flgSonota.txtSonota_SubTotal1 = false;
    }

if (isNumber("txtSonota_Total1")) {
flgSonota.txtSonota_Total1 = true;
    } else {
flgSonota.txtSonota_Total1 = false;
    }

if(flgSonota.txtSonota_Kamotu1 && flgSonota.txtSonota_Kamotu2 && flgSonota.txtSonota_Kamotu3 &&
flgSonota.txtSonota_Kamotu4 && flgSonota.txtSonota_Bus1   && flgSonota.txtSonota_Bus2  &&
flgSonota.txtSonota_JK_J1 && flgSonota.txtSonota_JK_K1 && flgSonota.txtSonota_JK_J2 &&
flgSonota.txtSonota_JK_K2 && flgSonota.txtSonota_JK_J3 && flgSonota.txtSonota_JK_K3 &&
flgSonota.txtSonota_SubTotal1  && flgSonota.txtSonota_Total1)
{
return true;

}else{
return false;
}

}

//=============================
//check Goukei
//=============================
var flgGoukei =
{
txtGoukei_Kamotu1:false,
txtGoukei_Kamotu2:false,
txtGoukei_Kamotu3:false,
txtGoukei_Kamotu4:false,
txtGoukei_Bus1:false,
txtGoukei_Bus2:false,
txtGoukei_JK_J1:false,
txtGoukei_JK_K1:false,
txtGoukei_JK_J2:false,
txtGoukei_JK_K2:false,
txtGoukei_JK_J3:false,
txtGoukei_JK_K3:false,
txtGoukei_SubTotal1:false,
txtGoukei_Total1:false
};

function checkGoukei(){
if (isNumber("txtGoukei_Kamotu1")) {
flgGoukei.txtGoukei_Kamotu1 = true;
}else{
flgGoukei.txtGoukei_Kamotu1 = false;
}
if (isNumber("txtGoukei_Kamotu2")) {
flgGoukei.txtGoukei_Kamotu2 = true;
    } else {
flgGoukei.txtGoukei_Kamotu2 = false;
    }
    if (isNumber("txtGoukei_Kamotu3")) {
flgGoukei.txtGoukei_Kamotu3 = true;
    } else {
flgGoukei.txtGoukei_Kamotu3 = false;
    }
if (isNumber("txtGoukei_Kamotu4")) {
flgGoukei.txtGoukei_Kamotu4 = true;
    } else {
flgGoukei.txtGoukei_Kamotu4 = false;
    }    
  if (isNumber("txtGoukei_Bus1")) {
flgGoukei.txtGoukei_Bus1 = true;
    } else {
flgGoukei.txtGoukei_Bus1 = false;
    }
  if (isNumber("txtGoukei_Bus2")) {
flgGoukei.txtGoukei_Bus2 = true;
    } else {
flgGoukei.txtGoukei_Bus2 = false;
    }
if (isNumber("txtGoukei_JK_J1")) {
flgGoukei.txtGoukei_JK_J1 = true;
    } else {
flgGoukei.txtGoukei_JK_J1 = false;
    }

if (isNumber("txtGoukei_JK_K1")) {
flgGoukei.txtGoukei_JK_K1 = true;
    } else {
flgGoukei.txtGoukei_JK_K1 = false;

    }
if (isNumber("txtGoukei_JK_J2")) {
flgGoukei.txtGoukei_JK_J2 = true;
    } else {
flgGoukei.txtGoukei_JK_J2 = false;
    }

if (isNumber("txtGoukei_JK_K2")) {
flgGoukei.txtGoukei_JK_K2 = true;
    } else {
flgGoukei.txtGoukei_JK_K2 = false;
    }
         
    if (isNumber("txtGoukei_JK_J3")) {
flgGoukei.txtGoukei_JK_J3 = true;
    } else {
flgGoukei.txtGoukei_JK_J3 = false;
    }
 
if (isNumber("txtGoukei_JK_K3")) {
flgGoukei.txtGoukei_JK_K3 = true;
    } else {
flgGoukei.txtGoukei_JK_K3 = false;
    }

if (isNumber("txtGoukei_SubTotal1")) {
flgGoukei.txtGoukei_SubTotal1 = true;
    } else {
flgGoukei.txtGoukei_SubTotal1 = false;
    }

if (isNumber("txtGoukei_Total1")) {
flgGoukei.txtGoukei_Total1 = true;
    } else {
flgGoukei.txtGoukei_Total1 = false;
    }

if(flgGoukei.txtGoukei_Kamotu1 && flgGoukei.txtGoukei_Kamotu2 && flgGoukei.txtGoukei_Kamotu3 &&
flgGoukei.txtGoukei_Kamotu4 && flgGoukei.txtGoukei_Bus1   && flgGoukei.txtGoukei_Bus2  &&
flgGoukei.txtGoukei_JK_J1 && flgGoukei.txtGoukei_JK_K1 && flgGoukei.txtGoukei_JK_J2 &&
flgGoukei.txtGoukei_JK_K2 && flgGoukei.txtGoukei_JK_J3 && flgGoukei.txtGoukei_JK_K3 &&
flgGoukei.txtGoukei_SubTotal1  && flgGoukei.txtGoukei_Total1)
{
return true;

}else{
return false;
}

}


function checkForms() {

//check Header
if (checkFormsHeader() === false) {
return false;
}

        //check Mito
if(checkMito() === false){
return false;
}

//check Tuchiura
if(checkTuchiura() === false){
return false;
}

//check Tukuba
if(checkTukuba() === false){
return false;
}

//check Sonota
if(checkSonota() === false){
return false;
}

//check Goukei
if(checkGoukei() === false){
return false;
}
}

function validateForm() {

    if (!isEmpty("txtYearRep")) {
        return false;
    }

    if (!isEmpty("txtMonthRep")) {
        return false;
    }


    if (!isNumber("txtYearRep")) {
        return false;
    }

    if (!isNumber("txtMonthRep")) {
        return false;
    }

    if (!isEmpty("txtFileName")) {
        document.getElementById("lblMsg").value = "ファイル名を入力してください。";
        return false;
    } else {
        document.getElementById("lblMsg").value = "";
    }

}
// ==============================
//  カーソル制御処理
// ==============================
function setFocus() {
    document.getElementById('txtYearRep').onkeydown
        = function () {
            if (event.keyCode == 13) {
                document.getElementById('txtMonthRep').focus();
                document.getElementById('txtMonthRep').select();
                return false;
            }
        }

    document.getElementById('txtMonthRep').onkeydown
        = function () {
            if (event.keyCode == 13) {
                document.getElementById('btnDownload').focus();
                document.getElementById('btnDownload').select();
                return false;
            }
        }
}


function setFileName() {

    var txtFileName = document.getElementById("txtFileName");
    var today = new Date();
    //年月日
    var YearMonthDay = String(today.getFullYear()) +
        String(covertDigit2(today.getMonth()+1)) +
        String(covertDigit2(today.getDate()));


    //時間分秒
    var HMS = String(covertDigit2(today.getHours())) +
              String(covertDigit2(today.getMinutes())) +
              String(covertDigit2(today.getSeconds()));

    var txtYearRep = document.getElementById("txtYearRep").value;
    var txtMonthRep = document.getElementById("txtMonthRep").value;
    var lblEra = document.getElementById("lblEra").innerHTML;

    //西暦に直す
    var SeirekiYearRep = warekiToSeireki(lblEra, txtYearRep);


    var txtFileName = String(SeirekiYearRep) + String(covertDigit2(txtMonthRep)) + "Jisseki" +
                              String(YearMonthDay) +
                              String(HMS) +
                              ".csv";

    document.getElementById("txtFileName").value = txtFileName;

}

function covertDigit2(param) {
    param=param*1
    if (param === 1 || param === 2 || param === 3 || param === 4
         || param === 5 || param === 6 || param === 7 || param === 8
           || param === 9
        ) {
        return "0" + param;
    }
    return param;
}

JavaScript入力チェックサンプル

//=============================
// 先頭の空白を削除
//=============================
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
//=============================
// 末尾の空白を削除
//=============================
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}
//=============================
// 先頭および末尾の空白を削除
//=============================
String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
//=============================
// 先頭および末尾の、全角空白、半角空白、タブ、を削除
//=============================
String.prototype.jtrim = function () {
    return unescape(escape(this).replace(/^(%u3000|%20|%09)+|(%u3000|%20|%09)+$/g, ""));
}

//=============================
//数値のチェック
//=============================
function isNumber(id) {
    //数値かどうかのチェック
    var obj = document.getElementById(id);

    //エラーの時は背景色を変える
    if (isNaN(obj.value)) {
        //document.getElementById(id).style.backgroundColor = "Pink";
        //document.getElementById(id).focus();
        isError(id);
        return false;
    } else {
        //document.getElementById(id).style.backgroundColor = "White";
        //-1とかも数値扱い
        isOk(id);
        return true;

    }
}

function isDecimal(id) {
    var obj = document.getElementById(id);
    if (obj.value.match(/^[-]?[0-9]+(¥.[0-9]+)?$/)) {
        return true;
    }
    return false;
}

//=============================
//必須のチェック
//=============================
function isEmpty(id) {
    //数値かどうかのチェック
    var obj = document.getElementById(id);

    //エラーの時は背景色を変える
    if (obj.value == "") {

    //    document.getElementById(id).style.backgroundColor = "Pink";
        //    document.getElementById(id).focus();
        isError(id);
        return false;
    } else {
        //document.getElementById(id).style.backgroundColor = "White";
        isOk(id);
        return true;
    }
}

//=============================
//エラー時に色を変える
//=============================
function isError(id) {
    document.getElementById(id).style.backgroundColor = "Pink";
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function isOk(id) {
    document.getElementById(id).style.backgroundColor = "White";

}



//和暦を西暦に変換(igarashi)
function warekiToSeireki(Gengo, y) {
    y = parseInt(y, 10);
    var seireki;

    switch (Gengo) {
        case "平成":
            if ((y > 0)) {
                seireki = 1988 + y; // 平成
            }
            break;
        case "昭和":
            if ((y > 0) && (y < 65)) {
                seireki = 1925 + y;
            }
            break;

        case "大正":
            if ((y > 0) && (y < 16)) {
                seireki = 1911 + y;
            }
            break;

        case "明治":
            if ((y > 0) && (y < 46)) {
                seireki = 1867 + y;
            }
            break;
    }

    return seireki;
}

// ==============================
//  カーソル制御処理
// ==============================
function setFocus() {
    //上部
    document.getElementById('txtYearRep0').onkeydown
   = function () {
       if (event.keyCode == 13) {
           document.getElementById('txtMonthRep0').focus();
           document.getElementById('txtMonthRep0').select();
           return false;
       }
   }

    document.getElementById('txtMonthRep0').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtYear').focus();
       document.getElementById('txtYear').select();
       return false;
   }
}
    document.getElementById('txtYear').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtMonth').focus();
       document.getElementById('txtMonth').select();
       return false;
   }
}

    document.getElementById('txtMonth').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtDay').focus();
       document.getElementById('txtDay').select();
       return false;
   }

}

    document.getElementById('txtDay').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtSyamei').focus();
       document.getElementById('txtSyamei').select();
       return false;
   }

}

    document.getElementById('txtSyamei').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtTantou').focus();
       document.getElementById('txtTantou').select();
       return false;
   }

}

    document.getElementById('txtTantou').onkeydown
= function () {
   if (event.keyCode == 13) {
       document.getElementById('txtMito_Kamotu1').focus();
       document.getElementById('txtMito_Kamotu1').select();
       return false;
   }

}





Wijmoサンプル

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--jQuery References-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>

<!--Theme-->
<link href="http://cdn.wijmo.com/themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" title="rocket-jqueryui" />

<!--Wijmo Widgets CSS-->
<link href="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.1.0.min.css" rel="stylesheet" type="text/css" />

<!--Wijmo Widgets JavaScript-->
<script src="http://cdn.wijmo.com/jquery.wijmo-open.all.2.1.0.min.js" type="text/javascript"></script>
<script src="http://cdn.wijmo.com/jquery.wijmo-complete.all.2.1.0.min.js" type="text/javascript"></script>
<!--RequireJs-->
<script type="text/javascript" src="http://cdn.wijmo.com/external/require.js"></script>
<script>

//TODO:jQueryに組み込む
$(function () {
//必須チェック
$('#login').click(function(){
var strDate = $('#txtdate1').val().trim().split("/");
//alert(date1[0]);
var intYear = strDate[0]*1;
var intMon  = strDate[1]*1;
var intDay  = strDate[2]*1;
//alert(inputedDate=date1[2]);//01
//alert(inputedDate=date1[2]*1);//1になってくれた
var today = new Date();

if(intDay  !== today.getDate())
{
alert("日付が現在日と一致してない");
return fasle;
}else{
//月が同じ?
}

if(intDay  >= today.getDate())
{
alert("日付が現在日よりすぎてる");
}


if(intDay  <= today.getDate())
{
alert("日付が現在日より前");
}

//alert(today);
//alert(today.getYear());
alert(today.getFullYear());
alert(today.getMonth()+1);//0から //5
alert(today.getDate());//1 一桁ものは、考慮が必要ね

})

});

</script>
<script type="text/javascript">
    requirejs.config({
        baseUrl: "http://cdn.wijmo.com/amd-js/3.20143.59",
            paths: {
                "jquery": "jquery-1.11.1.min",
                "jquery-ui": "jquery-ui-1.11.0.custom.min",
                "jquery.ui": "jquery-ui",
                "jquery.mousewheel": "jquery.mousewheel.min",
                "globalize": "globalize.min",
                "bootstrap": "bootstrap.min", //Needed if you use Bootstrap.
                "knockout": "knockout-3.1.0" //Needed if you use Knockout.
            }
    });
</script>
<title>Login</title>
</head>
<body>
<div class="container">
<div class="container">
<form id="frmInput" name="frmInput" method="post" >
<div class="row">
<div class="col-sm-3">
</div>
<div class="col-sm-2">
<label for="txtdate1"  class="lbl" >日付</label>
</div>
<div  class="col-sm-7">
<input id="txtdate1"  class="txt" name="date1" type="text" id="date1"  placeholder="date1" value="2015/05/01"/>
</div>
<input type="button" id="login" value="チェック"/>
</div>
</form>
</div>
<script id="scriptInit" type="text/javascript">
        require(["globalize.cultures"], function () {
          Globalize.culture("ja-JP");
        });
 
        require(["wijmo.wijgrid"], function () {
            $(document).ready(function () {
 
                // bind the grid
                $("#demo").wijgrid({
                    editingMode: "cell",
                    allowKeyboardNavigation: true,
                    highlightCurrentCell: true,
                    selectionMode: "none",
                    afterCellEdit: onAfterCellEdit,
                    allowSorting: true,
                    data: getData(12),
                    columnsAutogenerationMode: "none",
                    columns: [
                        { dataKey: "Country", headerText: "Country", dataType: "string", aggregate: "count", readonly :false, footerText: "Count: <b>{0}</b>" },
                        { dataKey: "ProductName", headerText: "Product Name", dataType: "string" },
                        { dataKey: "UnitPrice", headerText: "Unit Price", dataType: "currency", aggregate: "average", footerText: "Avg: <b>{0}</b>" },
                        { dataKey: "Quantity", headerText: "Quantity", dataType: "number", dataFormatString: "n0", aggregate: "sum", footerText: "Sum: <b>{0}</b>" },
                        { dataKey: "Discount", headerText: "Discount", dataType: "number", dataFormatString: "p0", aggregate: "max", footerText: "Max: <b>{0}</b>" },
                        { dataKey: "OrderDate", headerText: "Order Date", dataType: "datetime", dataFormatString: "MMM-dd-yyyy", textAlignment: "center" },
                        { dataKey: "Overseas", headerText: "Overseas", dataType: "boolean" }
                    ] ,
                    loaded: function (e) {
                        var _event = e;
                        //$("#demo")
                        //表の値取得
                        var gridArray= $("#demo").wijgrid("option", "data");
                        //ループで、値を見て、プロパティを変える?
                        //セルPropertyとれるのか?
                        var target = e.target

                        var rows = e.target.rows
                        var lenRows = rows.length//ヘッダー行含む
                        rows[1].cells[2].disabled = true;
                        rows[1].cells[6].disabled = true;
                        //長さ分ループして、gridArrayと比較。
                        //比較のフラグを見て、プロパティを変える?

                        //alert(lenRows)

                        var pageSize = $("#demo").wijgrid("option", "pageSize");
                           
                    }

                });
            });
        });
 
        // perform validation after edits
        function onAfterCellEdit(e, args) {
 
            // check the new cell value
            var valid = true;
            var value = args.cell.value();
            switch (args.cell.column().dataKey) {
                case "UnitPrice":
                case "Quantity":
                    if (value < 0) valid = false;
if(!valid) alert("数値は0以上");
                    break;
                case "Discount":
                    if (value < 0 || value > .3) valid = false;
                    break;
            }
 
            // if invalid, apply error style to the cell
            if (!valid) {
                $(args.cell.container()).addClass("ui-state-error");
            } else {
                $(args.cell.container()).removeClass("ui-state-error");
            }
        }
 
        // random data generators
        function getData(count) {
            var data = [];
            var country = "USA,UK,Germany,Italy,Japan,Brazil,Canada".split(",");
            var name = "Lorem,Ipsum,Dolor,Amet,Consectetur".split(",");
            var suffix = "LLC,Inc".split(",");
            for (var i = 0; i < count; i++) {
                data.push({
                    TransactionID: i,
                    Country: getString(country),
                    ProductName: getString(name) + " " + getString(suffix),
                    UnitPrice: Math.floor(getNumber(5, 10)),
                    Quantity: Math.floor(getNumber(1, 5)) * 10,
                    Discount: getNumber(0, 0.3),
                    OrderDate: getDate(i),
                    Overseas: Math.random() > 0.8
                });
            }
            return data;
        }
        function getString(arr) {
            return arr[Math.floor((Math.random() * arr.length))];
        }
        function getNumber(lo, hi) {
            return lo + Math.random() * (hi - lo);
        }
        function getDate(daysAgo) {
            return new Date((new Date()).getTime() - daysAgo * 24 * 3600 * 1000);
        }
    </script>
 
    <div class="container">
        <div class="header">
            <h2>Editing</h2>
        </div>
 
        <div class="main demo">
            <!-- Begin demo markup -->
            <table id="demo">
            </table>
            <!-- End demo markup -->
 
            <div class="demo-options">
                <!-- Begin options markup -->
                <!-- End options markup -->
            </div>
        </div>
        <div class="footer demo-description">
            <p>
                このサンプルではeditingMode オプションを "cell"に設定してグリッドを編集する方法を紹介します。
            </p>
            <p>
                ユーザーが編集したいセルを選択するには、キーボードを使用できるようにサンプルもallowKeyboardNavigationをtrueに設定します。
            </p>
            <p>
                サンプルでは、検証を実行するafterCellEditイベントを使用する方法を説明します。
            </p>
        </div>
    </div>

</div>
</body>
</html>

JavaScriptでASP.NETのページ遷移時に、ASPでセッション渡し

function myFunction() {
    <%
    Session("key1") = "111"
    %>
        window.open("WebForm2.aspx");
}