2015年6月18日木曜日
2015年6月14日日曜日
jQuery JavaScript 対比メモ
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="./jquery-2.1.4.js" type="text/javascript"> </script>
<script>
$(function () {
//$(document).on('click', 'div', function() {
// $(this).css('background', 'red');
//});
var targetInput = ':text, :password, textarea';
$(targetInput).on('focus' , function(){
$(this).css('background-color','Pink');
});
$(targetInput).on('blur', function(){
$(this).css('background-color','White');
});
$(targetInput).blur(function(){
if ($(this).find('.jFocus')) {
$(this).removeClass('jFocus');
}
});
$('input:focus').css('background-color', 'Pink')
$('div').css('background-color', 'Aqua');
$('input[name="btn1"]').on('click',function(){
//alert('AAA');
var regEx = /^[0-9]{1,2}/;
var txt = $('input[name="txt1"]').val();
if(txt.match(regEx)){
//alert('matched');
//document.getElementById('Result').innerText='<b>matched</b>'
//document.getElementById('Result').innerHTML='<b>matched</b>'
//$('#Result').text('Matched');
$('#Result').html('<b>Matched</b>');
//$('#Result').
}else{
//alert('Not matched');
//document.getElementById('Result').innerHTML='<b>Not matched</b>'
}
});
//$('#Buttion1').click(function (){
// alert('hello');
//});
});
function button_clicked(){
//alert("abcde");
var regEx = /^[0-9]{1,2}/;
var txt = document.getElementById('Text1').value;
if(txt.match(regEx)){
//alert('matched');
//document.getElementById('Result').innerText='<b>matched</b>'
document.getElementById('Result').innerHTML='<b>matched</b>'
}else{
//alert('Not matched');
document.getElementById('Result').innerHTML='<b>Not matched</b>'
}
};
</script>
<title></title>
</head>
<body>
<div>
<input id="Text1" type="text" name="txt1" />
</div>
<div>
<input id="Button1" name="btn1" type="button" value="button1" />
<input id="Button2" type="button" value="button2" onClick="button_clicked();"/>
</div>
<div id="Result" >
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="./jquery-2.1.4.js" type="text/javascript"> </script>
<script>
$(function () {
//$(document).on('click', 'div', function() {
// $(this).css('background', 'red');
//});
var targetInput = ':text, :password, textarea';
$(targetInput).on('focus' , function(){
$(this).css('background-color','Pink');
});
$(targetInput).on('blur', function(){
$(this).css('background-color','White');
});
$(targetInput).blur(function(){
if ($(this).find('.jFocus')) {
$(this).removeClass('jFocus');
}
});
$('input:focus').css('background-color', 'Pink')
$('div').css('background-color', 'Aqua');
$('input[name="btn1"]').on('click',function(){
//alert('AAA');
var regEx = /^[0-9]{1,2}/;
var txt = $('input[name="txt1"]').val();
if(txt.match(regEx)){
//alert('matched');
//document.getElementById('Result').innerText='<b>matched</b>'
//document.getElementById('Result').innerHTML='<b>matched</b>'
//$('#Result').text('Matched');
$('#Result').html('<b>Matched</b>');
//$('#Result').
}else{
//alert('Not matched');
//document.getElementById('Result').innerHTML='<b>Not matched</b>'
}
});
//$('#Buttion1').click(function (){
// alert('hello');
//});
});
function button_clicked(){
//alert("abcde");
var regEx = /^[0-9]{1,2}/;
var txt = document.getElementById('Text1').value;
if(txt.match(regEx)){
//alert('matched');
//document.getElementById('Result').innerText='<b>matched</b>'
document.getElementById('Result').innerHTML='<b>matched</b>'
}else{
//alert('Not matched');
document.getElementById('Result').innerHTML='<b>Not matched</b>'
}
};
</script>
<title></title>
</head>
<body>
<div>
<input id="Text1" type="text" name="txt1" />
</div>
<div>
<input id="Button1" name="btn1" type="button" value="button1" />
<input id="Button2" type="button" value="button2" onClick="button_clicked();"/>
</div>
<div id="Result" >
</div>
</body>
</html>
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;
}
}
// 先頭の空白を削除
//=============================
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;
}
}
JavaScriptでASP.NETのページ遷移時に、ASPでセッション渡し
function myFunction() {
<%
Session("key1") = "111"
%>
window.open("WebForm2.aspx");
}
<%
Session("key1") = "111"
%>
window.open("WebForm2.aspx");
}
登録:
投稿 (Atom)