var NO_BLANK = "{name} must be filled"; var NOT_VALID = "{name} is worng."; String.prototype.trim = function(str) { str = this != window ? this : str; return str.replace(/^\s+/g,'').replace(/\s+$/g,''); } String.prototype.hasFinalConsonant = function(str) { str = this != window ? this : str; var strTemp = str.substr(str.length-1); return ((strTemp.charCodeAt(0)-16)%28!=0); } String.prototype.bytes = function(str) { str = this != window ? this : str; for(j=0; j 128) ? 2 : 1 } return len; } function validate(form) { for (i = 0; i < form.elements.length; i++ ) { var el = form.elements[i]; if (el.tagName == "FIELDSET") continue; el.value = el.value.trim(); var minbyte = el.getAttribute("MINBYTE"); var maxbyte = el.getAttribute("MAXBYTE"); var option = el.getAttribute("OPTION"); var match = el.getAttribute("MATCH"); var glue = el.getAttribute('GLUE'); if (el.getAttribute("REQUIRED") != null) { if (el.value == null || el.value == "") { return doError(el,NO_BLANK); } } if (minbyte != null) { if (el.value.bytes() < parseInt(minbyte)) { return doError(el,"{name} is too short."); } } if (maxbyte != null && el.value != "") { var len = 0; if (el.value.bytes() > parseInt(maxbyte)) { return doError(el,"{name} is too long."); } } if (match && (el.value != form.elements[match].value)) return doError(el,"{name} do not match"); if (option != null && el.value != "") { if (el.getAttribute('SPAN') != null) { var _value = new Array(); for (span=0; span