// isblank() - returns true if the value passed is blank or emtpy, false // otherwise function isblank(value) { if (value.length == 0) { return true; } for (i=0; i '9') { return false; } } return true; } // to_dollar() - accepts a string value, assumed to be numeric // Converts the number into a dollar-like value // Examples: 5 -> 5.00 // 5.1 -> 5.10 // 5.12 -> 5.12 // 5.123 -> 5.12 // 5.789 -> 5.79 function to_dollar(amount) { var strval; var intval; amount *= 100; // Make 5.01 = 501 or 5.2345 = 523.45 amount = Math.round(amount); // Round up or down amount /= 100; // Make 523 back to 5.23 // or: // amount = (Math.round(amount * 100)) / 100; intval = parseInt(amount.toString()); // Get the integer part only if (intval == amount) { // Same as number? Need to add .00 strval = intval + ".00"; } else { amount = amount.toString(); var numparts = amount.split("."); strval = amount; if (numparts[1].length == 1) strval += "0"; // Add 0 to 5.2 to make 5.20 } return(strval); // Return the amount } // isZip() - returns true if the value passed is a valid zip code, or // false if it is not. function isZip(value) { if (value.length != 5 && value.length != 10) { return false; } for (i=0; i<5; i++) { if (value.charAt(i) < '0' || value.charAt(i) > '9') { return false; } } if (value.length == 5) return true; if (value.charAt(5) != "-") return false; for (i=6; i<10; i++) { if (value.charAt(i) < '0' || value.charAt(i) > '9') { return false; } } return true; }