/////////////////////////////////////////////////// //Java script contains functions for Radius and Coordinates // // Author: RAM, modified by JVS // Date :08/09/01 // /////////////////////////////////////////////////// ////////////////////////////// // Validate Radius ///////////////////////////// function verRadius( radius, metricValue) { // radius must be numeric if (!IsAllDigits(radius) || (radius == ".") || (radius == "-")) { return("Radius must be numeric"); }// endif Validating radius is numeric if (metricValue == "Miles") { if( radius > 200 || radius <= 0 ) { return("Radius is required and must be between 0 and 200 miles"); } } if (metricValue == "Kilometers") { if( radius > 321.9|| radius <= 0 ) { return("Radius is required and must be between 0 and 321.9 kilometers"); } } return true; }//end for verRadius() ////////////////////////////// // Validate Heights ///////////////////////////// function verHeightValue( height, metricValue) { // Height must be numeric if (!IsAllDigits(height) || (height == ".") || (height == "-")) { return ("Height must be numeric"); }// endif for Validating LatDeg is numeric if (metricValue == "Meters") { if( height > 9999 || height < 1 ) { return("Height is required and must be between 1 and 9999 meters"); } } if (metricValue == "Feet") { if( height > 32804.7 || height < 1 ) { return("Height is required and must be between 1 and 32804.7 feet"); } } return true; }//end for verRadius() ////////////////////////////// //Validate Latitude Degree ///////////////////////////// function verLatDeg(latDeg) { // latDeg must be numeric if (!IsAllDigits(latDeg) || (latDeg== ".") || (latDeg== "-")) { return ("Latitude degrees must be numeric"); }// endif for Validating latDeg is numeric else if (latDeg.indexOf(".") != -1 ) { return("Latitude degrees must be integer"); } // end elseif for Validating latDeg is interger // LatDeg mus be between 0 and 90 if( latDeg > 90 || latDeg < 0 ) { return("Latitude degrees are required and must be between 0 and 90"); }//End if for checking if latDeg has the correct values return true; }// end for verLatDeg function verLatDeg2(latDeg) { // latDeg must be numeric if (!IsAllDigits(latDeg) || (latDeg== ".") || (latDeg== "-")) { return ("Latitude degrees must be numeric"); }// endif for Validating latDeg is numeric else if (latDeg.indexOf(".") != -1 ) { return("Latitude degrees must be integer"); } // end elseif for Validating latDeg is interger return true; }// end for verLatDeg ////////////////////////////// //Validate Latitude Minutes ///////////////////////////// function verLatMin(latMin) { // LatMin must be numeric if (!IsAllDigits(latMin) || (latMin== ".") || (latMin== "-")) { return("Latitude minutes must be numeric"); }// Endif for checking if latMin is numeric else if ( latMin.indexOf(".") != -1 ) { return("Latitude minutes must be integer"); } // end elseif for Validating latMin is interger // LatMin must be between 60 and 0 if( latMin >= 60 || latMin < 0) { return("Latitude minutes are required and must be between 0 and 59"); }//Endif for checking the values of latMin. return true; }// end for verLatMin ////////////////////////////// //Validate Latitude Seconds ///////////////////////////// function verLatSec(latSec) { if (!IsAllDigits(latSec) || (latSec ==".") || (latSec =="-")) { return("Latitude seconds must be numeric"); }// Endif for checking if latSec is numeric if (latSec.indexOf(".")!= -1 && latSec.length > (latSec.indexOf(".")+2) ) { return("Latitude seconds must be only one digital right of decimal"); }// Endif for checking for Latitude is xx.x // LatSec must be between 60 and 0 if( latSec >= 60 || latSec < 0) { return("Latitude seconds are required and must be between 0 and 59.9"); }//Endif for checking the values of latSec. return true; }// end for verLatSec ////////////////////////////// //Validate Longitude Degree ///////////////////////////// function verLongDeg(longDeg) { // longDeg must be numeric if (!IsAllDigits(longDeg) || (longDeg ==".") || (longDeg =="-")) { return("Longitude degrees must be numeric"); }// endif for Validating longDeg is numeric else if ( longDeg.indexOf(".") != -1 ) { return("Longitude degrees must be integer"); } // end elseif for Validating longDeg is interger // LongDeg must be between 0 and 180 if( longDeg > 180 || longDeg < 0 ) { return("Longitude degrees are required and must be between 0 and 180"); }//End if for checking if longDeg has the correct values return true; }// end for verLongDeg function verLongDeg2(longDeg) { // longDeg must be numeric if (!IsAllDigits(longDeg) || (longDeg ==".") || (longDeg =="-")) { return("Longitude degrees must be numeric"); }// endif for Validating longDeg is numeric else if ( longDeg.indexOf(".") != -1 ) { return("Longitude degrees must be integer"); } // end elseif for Validating longDeg is interger return true; }// end for verLongDeg ////////////////////////////// //Validate Longitude Minutes ///////////////////////////// function verLongMin(longMin) { // LongMin must be numeric if (!IsAllDigits(longMin) || (longMin ==".") || (longMin =="-")) { return("Longitude minutes must be numeric"); }// Endif for checking if longMin is numeric else if ( longMin.indexOf(".") != -1 ) { return("Longitude minutes must be integer"); } // end elseif for Validating longMin is interger // LongMin must be between 60 and 0 if( longMin >= 60 || longMin < 0) { return("Longitude minutes are required and must be between 0 and 59"); }//Endif for checking the values of longtMin. return true; }// end for verLongMin ////////////////////////////// //Validate Longitude Seconds ///////////////////////////// function verLongSec(longSec) { // longSec must be numeric if (!IsAllDigits(longSec) || (longSec ==".") || (longSec =="-")) { return("Longitude seconds must be numeric"); } if (longSec.indexOf(".")!= -1 && longSec.length > (longSec.indexOf(".")+2) ) { return("Longitude seconds must be only one digital right of decimal"); }// Endif for checking for longSec is xx.x // LongSec must be between 60 and 0. if( longSec >= 60 || longSec < 0 ) { return("Longitude seconds are required and must be between 0 and 59.9"); } return true; }// end for verLongSec ////////////////////////////// // Validate Overall Structure Height ///////////////////////////// function verOverallStru(overallStrucHeight,metricValue) { /* overallStrucHeight must be numeric */ if (!IsAllDigits(overallStrucHeight) || (overallStrucHeight == ".") || (overallStrucHeight == "-")) { return("Overall Structure Height (AGL) must be numeric") }// endif for Validating overallStrucHeight is numeric if (overallStrucHeight.indexOf(".")!= -1 && overallStrucHeight.length > (overallStrucHeight.indexOf(".")+2) ) { return("Overall Structure Height (AGL) must be only one digital right of decimal"); }// Endif for checking for Overall Structure Height (AGL) if (metricValue == "Feet") { /* overallStrucHeight must be between 0 and 3280.8 */ if( parseFloat(overallStrucHeight) > 3280.8 || parseFloat(overallStrucHeight) < 0) { return("Overall structure height (AGL) is required and the value must be between 0 and 3280.8 feet (or the equivalent in meters)"); }//Endif for checking the values of overallStrucHeight. } if (metricValue == "Meters") { /* overallStrucHeight must be between 0 and 1000 */ if( parseFloat(overallStrucHeight) > 1000 || parseFloat(overallStrucHeight) < 0) { return("Overall structure height (AGL) is required and the value must be between 0 and 1000 meters (or the equivalent in feet)"); }//Endif for checking the values of overallStrucHeight. } return true; }// end for verOverallStru ////////////////////////////// // Validate Support Structure Height ///////////////////////////// function verSupportStru(supportStrucHeight,metricValue) { /* verSupportStru must be numeric */ if (!IsAllDigits(supportStrucHeight) || (supportStrucHeight == ".") || (supportStrucHeight == "-")) { return("Support Structure Height (AGL) must be numeric") }// endif for Validating verSupportStru is numeric if (supportStrucHeight.indexOf(".")!= -1 && supportStrucHeight.length > (supportStrucHeight.indexOf(".")+2) ) { return("Support Structure Height (AGL) must be only one digital right of decimal"); }// Endif for checking for Support Structure Height (AGL) if (metricValue == "Feet") { /* supportStrucHeight must be between 0 and 32808 */ if( parseFloat(supportStrucHeight) > 32808 || parseFloat(supportStrucHeight) < 0) { return("Support structure height (AGL) is required and the value must be between 0 and 32808 feet (or the equivalent in meters)"); }//Endif for checking the values of supportStrucHeight. } if (metricValue == "Meters") { /* supportStrucHeight must be between 0 and 10000 */ if( parseFloat(supportStrucHeight) > 10000 || parseFloat(supportStrucHeight) < 0) { return("Support structure height (AGL) is required and the value must be between 0 and 10000 meters (or the equivalent in feet)"); }//Endif for checking the values of supportStrucHeight. } return true; }// end for verSupportStru ////////////////////////////// // Validate Site Elevation ///////////////////////////// function verSiteElevation(siteElevation,metricValue) { /* siteElevation must be numeric */ if (!IsAllDigits(siteElevation) || siteElevation == "." || siteElevation == "-") { return("Site Elevation (AMSL) must be numeric") }// Endif for checking if siteElevation is numeric if (siteElevation.indexOf(".")!= -1 && siteElevation.length > (siteElevation.indexOf(".")+2) ) { return("Site Elevation (AMSL) must be only one digital right of decimal"); }// Endif for checking for Site Elevation (AMSL) if (metricValue == "Feet") { /* siteElevation must be between -500 and 20,501 feet */ if( parseFloat(siteElevation) > 20501 || parseFloat(siteElevation) < -500) { return("Site Elevation (AMSL) is required and the value must be between -500 and 20,501 feet (or the equivalent in meters)"); }//Endif for checking the values of siteElevation . } if (metricValue == "Meters") { /* siteElevation must be between -152.4 and 6248.7 */ if( parseFloat(siteElevation) > 6248.7 || parseFloat(siteElevation) < -152.4) { return("Site Elevation (AMSL) is required and the value must be between -152.4 and 6248.7 meters (or the equivalent in feet)"); }//Endif for checking the values of siteElevation . } return true; }// end for verSiteElevation ////////////////////////////// // Validate Frequency ///////////////////////////// function verFrequency(mhz) { // latDeg must be numeric if (!IsAllDigits(mhz)|| (mhz == ".") || (mhz == "-")) { return("Frequency must be numeric"); }// endif for Validating Frequency is numeric return true; }//end for verRadius() //////////////////////////////////////////////// // verZipCode // allows xxxxx or xxxxx-xxxx, or xxxxxxxxx // all numeric only //////////////////////////////////////////////// function verZipCode(zipCode) { var shortZipExp = /^\d{5}$/; //starts with 5 digits, ends with var longZipExp = /^\d{5}-\d{4}$/; //starts with five digits, has one -, //ends with 4 more digits var terseZipExp = /^\d{9}$/; //9 digits in a row if (! shortZipExp.test(zipCode) && ! longZipExp.test(zipCode) && ! terseZipExp.test(zipCode)) { return ("ZIP Code Invalid, enter either xxxxx ,xxxxx-xxxx or xxxxxxxxx"); }//end if return true; }// end for verZipCode //////////////////////////////////////////////// // validateLatLongFormat // allows Latitude DD-MM-SS.S // Longitude DDD-MM-SS.S // all numeric only //////////////////////////////////////////////// function validateLatLongFormat(value,latOrLong) { var latFormat = /^\d{2}-\d{2}-\d{2}.\d{1}$/; var longFormat = /^\d{3}-\d{2}-\d{2}.\d{1}$/; if (latOrLong == "lat") { if (! latFormat.test(value)) { return ("Latitude format incorrect, enter DD-MM-SS.S"); } } if (latOrLong == "long") { if (! longFormat.test(value)) { return ("Longitude format incorrect, enter DDD-MM-SS.S"); } } return true; }// end validateLatLongFormat