var Form_check = function()
{ }
Form_check.confirms = function(checkMsg, cancelMsg)
{ if("undefined" == typeof(checkMsg) ) checkMsg = "本当によろしいですか？"; if("undefined" == typeof(cancelMsg) ) cancelMsg = "キャンセルされました。"; if( window.confirm(checkMsg) )
{ return true;}
else
{ if(cancelMsg != "")
{ window.alert(cancelMsg);}
return false;}
}
Form_check.showByte = function(id, idSpan, max, separator, unit, color)
{ if("undefined" == typeof(separator) ) separator = "／"; if("undefined" == typeof(unit) ) unit = "バイト"; if("undefined" == typeof(color) ) color = "#ff0000"; var bytes = 0; var strlen; var str = document.getElementById(id).value; str = str.replace(/\n\r/g, "\n"); str = str.replace(/\r\n/g, "\n"); str = str.replace(/\r/g, "\n"); str = str.replace(/\n/g, "\n\r"); strlen = str.length; for(var y = 0; y < strlen; y++)
{ bytes += 1 + Number(str.charCodeAt(y) > 0xff);}
str = bytes + separator + max + unit; document.getElementById(idSpan).innerHTML = str; document.getElementById(idSpan).style.color = max < bytes ? color : "";}
Form_check.showByte_openWysiwyg = function(idSpan, max, no, separator, unit, color)
{ if("undefined" == typeof(no) ) no = 0; if("undefined" == typeof(separator) ) separator = "／"; if("undefined" == typeof(unit) ) unit = "バイト"; if("undefined" == typeof(color) ) color = "red"; var bytes; var idoc; var str; idoc = document.getElementsByTagName('iframe')[no].contentWindow.document; idoc = idoc.body.innerHTML; idoc = idoc.replace(/&lt;/g, "<"); idoc = idoc.replace(/&gt;/g, ">"); idoc = idoc.replace(/\n\r/g, ""); idoc = idoc.replace(/\r\n/g, ""); idoc = idoc.replace(/\n/g, ""); idoc = idoc.replace(/\r/g, ""); idoc = idoc.replace(/<BR><HR id=null><BR>/g, "<HR id=null>"); idoc = idoc.replace(/[^0-9a-zｱ-ﾝﾞﾟｧｨｩｪｫｯｬｭｮｰ､｡｢｣\!\"\#\$\%\&\'\(\)\-\=\^\~\\\|\@\`\[\{\;\+\:\*\]\}\,\<\.\>\/\?\_\ ]/ig,"##"); bytes = idoc.length; str = bytes + separator + max + unit; document.getElementById(idSpan).innerHTML = str; document.getElementById(idSpan).style.color = max < bytes ? color : "";}
Form_check.showStrLen = function(id, idSpan, max, separator, unit, color)
{ if("undefined" == typeof(separator) ) separator = "／"; if("undefined" == typeof(unit) ) unit = "文字"; if("undefined" == typeof(color) ) color = "#ff0000"; var strlen = document.getElementById(id).value.length; var str = document.getElementById(id).value; document.getElementById(idSpan).innerHTML = strlen + separator + max + unit; document.getElementById(idSpan).style.color = max < strlen ? color : "";}
Form_check.showNl = function(id, idSpan, max, separator, unit, color)
{ if("undefined" == typeof(separator) ) separator = "／"; if("undefined" == typeof(unit) ) unit = "行数上限："; if("undefined" == typeof(color) ) color = "#ff0000"; var cnt; var str = document.getElementById(id).value; var o_reg = new RegExp("\n", "g"); str = str.replace(/\n\r/g, "\n"); str = str.replace(/\r\n/g, "\n"); str = str.replace(/\r/g, "\n"); str = str.replace(/\n/g, "\n\r"); cnt = str.match(o_reg); cnt = null == cnt ? 1 : cnt.length + 1; str = unit + cnt + separator + max; document.getElementById(idSpan).innerHTML = str; document.getElementById(idSpan).style.color = max < cnt ? color : "";}
Form_check.regist_limitMaxLength = function(id, len, err)
{ var el = document.getElementById(id); if(el.addEventListener)
{ el.addEventListener( "keyup", function(){ eval( "Form_check.limitMaxLength(id, len, err);" );}, false );}
else if(el.attachEvent)
{ el.attachEvent( "onkeyup", function(){ eval( "Form_check.limitMaxLength(id, len, err);" );} );}
}
Form_check.limitMaxLength = function(id, len, err)
{ var el = document.getElementById(id); if( el.value.length > len )
{ el.value = el.value.substr(0, len); if( "undefined" != typeof(err) )
{ alert(err);}
}
}

