function validateForm()
{
var amount = trimBetweenSpaces(trimBegEndSpaces(stripOffNonDigit(document.ccform.UMamount.value)));
var name = document.ccform.UMname.value;
var phone = document.ccform.UMbillphone.value;
var email = document.ccform.UMemail.value;
 
if (amount.length == 0)
{
alert ("Error: missing field amount.\n Please fill out the amount field.");
document.ccform.UMamount.focus == true;
return false;
}
 
if (name.length == 0 || !isAlphaSymbols(name, ".,' "))
{
alert ("Error: missing or incorrect field Name.\n Please fill out the name field.\nThe name field can only have Alpha Characters!");
document.ccform.UMname.focus == true;
return false;
}
 
if (phone.length == 0)
{
alert ("Error: missing field phone.\n Please fill out the phone number field.");
document.ccform.UMbillphone.focus == true;
return false;
}

if (email.length == 0)
{
alert ("Error: missing field email.\n Please fill out the email address field.");
document.ccform.UMemail.focus == true;
return false;
}
 
 
// Return true if a string is combination of alpha and given symbols.
function isAlphaSymbols(objValue, symbols) {
var ch
 
for (var i=0; i < objValue.length; i++) {
ch = objValue.charAt(i)
if (isAlphaChar(ch) == false) {
if (symbols.indexOf(ch) < 0)
return false
}
}
return true
}
 
// Return true of a character is an alphabet.
function isAlphaChar( ch ) {
return ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z"))
}
 
// Stiff off any non digit char
function stripOffNonDigit(objValue) {
var ch
var tempStr = new String()
 
for (var i=0; i<objValue.length; i++)
{
if (isDigitChar(objValue.charAt(i)) == true)
tempStr = tempStr + objValue.charAt(i)
}
 
return tempStr
}
 
// Return true if a character is a digit.
function isDigitChar( ch ) {
return ( ch >= "0" && ch <= "9" )
}
 
// Removes leading and trailing blanks from a value
function trimBegEndSpaces(object_value)
{
var leading_blanks = 0
var string_end = (object_value.length)-1
if (string_end < 0) string_end = 0
 
// find first nonblank: start with first character and scan forwards
while (leading_blanks <= string_end && object_value.charAt(leading_blanks) == " ")
{leading_blanks++}
 
// find last nonblank: start with last character and scan backwards
while (string_end > leading_blanks && object_value.charAt(string_end) == " ")
{string_end--}
 
return object_value = object_value.substring(leading_blanks,string_end+1)
}
 
// Remove any additional spaces
function trimBetweenSpaces(objValue) {
var blankExists = false
var newValue = new String()
var ch
 
for (var i=0; i < objValue.length; i++) {
ch = objValue.charAt(i)
if ( ch == " " ) {
if ( blankExists == false ) {
blankExists = true
newValue = newValue + ch
}
}
else {
newValue = newValue + ch
blankExists = false
}
}
if ( newValue == null )
return objValue
else
return newValue
}
}