UnescapeUTF8=function(str){ return str.replace(/%(E(0%[AB]|[1-CEF]%[89AB]|D%[89])[0-9A-F]|C[2-9A-F]|D[0-9A-F])%[89AB][0-9A-F]|%[0-7][0-9A-F]/ig,function(s){ var c=parseInt(s.substring(1),16); return String.fromCharCode(c<128?c:c<224?(c&31)<<6|parseInt(s.substring(4),16)&63:((c&15)<<6|parseInt(s.substring(4),16)&63)<<6|parseInt(s.substring(7),16)&63) }) }; var error = "%E5%85%A5%E5%8A%9B%E6%AC%84%E3%81%AB%E7%A9%BA%E7%99%BD%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99"; var colorful = new ColorfulInput; colorful.skip = ['submit']; colorful.color['focus'] = '#F6F6CC'; window.onload = function() { colorful.set(); } function ColorfulInput() { this.skip = []; this.color = { 'blur': '', 'focus': '#EEEEEE' }; this.set = function() { for (var i = 0; i < document.forms.length; i++) { for (var f = 0; f < document.forms[i].length; f++) { var elm = document.forms[i][f]; if(!this._checkSkip(elm)) continue; this._setColor(elm, 'focus'); this._setColor(elm, 'blur'); } } } this._checkSkip = function(elm) { for(var i in this.skip) { if(elm.type == this.skip[i]) return false; } return true; } this._setColor = function(elm, type) { var color = this.color[type]; var event = function() { elm.style.backgroundColor = color; }; if(elm.addEventListener) { elm.addEventListener(type, event, false); } else if(elm.attachEvent) { elm.attachEvent('on'+type, event); } else { elm['on'+type] = event; } } } function check(){ var er = 0; if(document.getElementById("chk1").value == ""){ er = 1; }else if(document.getElementById("chk2").value == ""){ er = 1; }else if(document.getElementById("chk3").value == ""){ er = 1; }else if(document.getElementById("chk4").value == ""){ er = 1; } if(er == 1){ alert(UnescapeUTF8(error)); return false; }else{ return true; } }