123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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;
- }
|