

function checkFormElementInRange(theForm, theFieldName, min, max)
{
    var theField         = theForm.elements[theFieldName];
    var val              = parseFloat(theField.value);

    if (typeof(min) == 'undefined') {
        min = 0;
    }
    if (typeof(max) == 'undefined') {
        max = Number.MAX_VALUE;
    }

    // It's not a number
    if (isNaN(val)) {
        theField.select();
        alert(errorMsg1);
        theField.focus();
        return false;
    }
    // It's a number but it is not between min and max
    else if (val < min || val > max) {
        theField.select();
        alert(val + errorMsg2);
        theField.focus();
        return false;
    }
    // It's a valid number
    else {
        theField.value = val;
    }

    return true;
} 


function checkFormElement(theForm, theFieldName)
{
    var isEmpty  = 1;
			var theField = theForm.elements[theFieldName];
			// Whether the replace function (js1.2) is supported or not
			var isRegExp = (typeof(theField.value.replace) != 'undefined');

			if (!isRegExp) {
					isEmpty      = (theField.value == '') ? 1 : 0;
			} else {
					var space_re = new RegExp('\\s+');
					isEmpty      = (theField.value.replace(space_re, '') == '') ? 1 : 0;
			}
			if (isEmpty) {
					theForm.reset();
					theField.select();
					theField.focus();
					return false;
			}
		
    return true;
} 

