function checkEmpty(aControlName, aTipMsg) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value == "") { alert(aTipMsg + "����Ϊ�գ�"); aObj.focus(); return false; } return true; } function checkRadioCheckboxEmpty(aControlName, aTipMsg) { var aObj = document.getElementsByName(aControlName); var count = aObj.length; var aEmpty = true; for (i = 0; i < count; i++) { if (aObj[i].checked == true) { aEmpty = false; break; } } if (aEmpty == true) { alert(aTipMsg + "����Ϊ�գ�"); aObj[0].focus(); return false; } return true; } function checkReferenceEmpty(aControlName, aTipMsg) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value == "") { alert(aTipMsg + "����Ϊ�գ�"); return false; } return true; } function checkRegx(aControlName, aTipMsg, aRegexValue) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value == "") return true; var regex = new RegExp(aRegexValue); if (!regex.test(aObj.value)) { alert(aTipMsg + "��ʽ����ȷ��"); aObj.focus(); return false; } return true; } function isNumeric(aControlName, aTipMsg, aRegexValue) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value == "") return true; var regex = new RegExp(aRegexValue); if (!regex.test(aObj.value)) { alert(aTipMsg + "������ֵ��"); aObj.focus(); return false; } return true; } function checkRange(aControlName, aTipMsg, maxValue, minValue) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value == "") return true; var aCompareValue = parseFloat(aObj.value); if (maxValue != "" && aCompareValue > maxValue) { alert(aTipMsg + "���ܴ��� " + maxValue + " ��"); aObj.focus(); return false; } if (minValue != "" && aCompareValue < minValue) { alert(aTipMsg + "����С�� " + minValue + " ��"); aObj.focus(); return false; } return true; } function checkMaxLength(aControlName, aTipMsg, maxLength) { var aObj = document.forms[0].elements[aControlName]; if (aObj.value.length > maxLength) { alert(aTipMsg + "��ݳ��Ȳ��ܴ��� " + maxLength + " λ��"); aObj.focus(); return false; } return true; } function validateAll(aControlName, aTipMsg, dataType, theMaxLength, theScaleSize) { if (dataType == "number") { if (isNumeric(aControlName, aTipMsg, "^(-|\\+)?\\d+(\\.\\d+)?$")) return true; else { document.forms[0].elements[aControlName].focus; return false; } } else if (dataType == "string") { if (checkMaxLength(aControlName, aTipMsg, theMaxLength)) return true; else { document.forms[0].elements[aControlName].focus; return false; } } return true; }