/*************** Verify Form Script  ********************//* from Freeway's Validate form action** Edited on 08/09/04  by David Yun for Blue Iceberg LLC** Fixed radio and checkbox form element validation*/function isNum(s){    var c, i;    if (s==null) return false;    for (i=0;i<s.length;i++) {        c=s.charAt(i);         if (((c>'9')||(c<'0'))&&(c!='.')&&(c!='-'))             return false;    }    return true;}function isBlank(s) {    var c, i;    if (s==null) return true;    for (i=0;i<s.length;i++) {        c=s.charAt(i);         if ((c!=' ')&&(c!='\n')&&(c!='\t'))             return false;    }    return true;}function VerifyForm() {    var f = this;    var i, e;     var empty_fields='';    var empty_radio = new Array();    var errors=''; var msg='';    for (i=0;i<f.length;i++)    {        e=f.elements[i];        if(e.name!=null && e.name.length>0 && e.validate!=null)        {            if ((e.type=='textarea')||(e.type=='text'))            {                if (isBlank(e.value))                {                    empty_fields += "\n    " + e.name;                    continue;                }                var hasmax = !isBlank(e.max);                var hasmin = !isBlank(e.min);                if (e.numeric||hasmax||hasmin)                {                    var num=isNum(e.value);                    var v=(num)?parseFloat(e.value):0;                    if(!num||(hasmin&&v<e.min)||(hasmax&&v>e.max))                    {                        errors += '- the Field '+e.name+' must be a number';                        if (hasmin)                            errors += ' that is greater than ' + e.min;                        if (hasmax&&hasmin)                            errors += ' and less than '+e.max;                        else if (hasmax)                            errors += ' that is less than '+e.max;                            errors+='.\n';                    }                }            }                        // Check radio/checkbox buttons                 if (e.type=="checkbox" || e.type=="radio")            {                // if this radio group isn't checked yet, set to 0                // in the empty_radio array                if (!e.checked && empty_radio[e.name]!=1) {                    empty_radio[e.name] = 0;                                 continue;                // if it's checked, set to 1                } else if (e.checked) {                    empty_radio[e.name] = 1;                    continue;                }                        }			if(e.type=='select-one')			{				if(e.value == 'select')				{					empty_fields += "\n    " + e.name;				}			}            //alert(e.type)         }    }     // Loop and check if any radio buttons or    // check boxes were left empty    for (name in empty_radio) {        if (empty_radio[name]==0) {            empty_fields += "\n    " + name;        }    }     if (!empty_fields&&!errors)    return true;     msg+='The form was not submitted because of the following Errors:\n\n';    if(empty_fields)    {        msg+='- The following Fields are empty:'+empty_fields+'\n';        if (errors)            msg+='\n';    }    msg+=errors;    alert(msg)    return false;}
