
// Absolute Form Processor XE V1.0 : Form Validation System
// Copyright(c)2000 - 2003 XIGLA SOFTWARE
// http://www.xigla.com

function cancelsubmit(msg,element){
	alert(msg);
	element.focus();
	return false
}



function isNumeric(what){
    if (what.search(/^[-+]?\d+(\.\d+)?$/) != -1)
        return true;
    else
        return false;
}

function isInteger(what){
	if (what.search(/^[-+]?[1-9]\d*.?[0]*$/) != -1)
        return true;
    else
        return false;
}


function isEmail(what) {
	// Works
    if (what.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isAlphanumeric(what){
	// ANY alphanumeric string with spaces, commas, dashes.
    if (what.search(/^[a-zA-Z0-9\s.\-]+$/) != -1)
        return true;
    else
        return false;
}

function isAlphabetic(what){
    if (what.search(/^[a-zA-Z\s]+$/) != -1)
        return true;
    else
        return false;
}

function noSpaces(what){
    if (what.search(/\s/) != -1)
        return false;
    else
        return true;
}

function isCC(what){
    if (what.search(/^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$/) != -1)
        return true;
    else
        return false;
}


function xlaAFPvalidate(xlaAFPform){
if (xlaAFPform.FirstName){if (xlaAFPform.FirstName.value==''){return cancelsubmit('Field \'FirstName\' is required',xlaAFPform.FirstName)}if (!isAlphabetic(xlaAFPform.FirstName.value)){return cancelsubmit('Field \'FirstName\' can only contain alphabetic characters.',xlaAFPform.FirstName)}if (xlaAFPform.FirstName.value.length>15){return cancelsubmit('Field \'FirstName\' cannot contain more than 15 characters.',xlaAFPform.FirstName)}if (xlaAFPform.FirstName.value.length<2){return cancelsubmit('Field \'FirstName\' cannot contain less than 2 characters.',xlaAFPform.FirstName)}if (!noSpaces(xlaAFPform.FirstName.value)){return cancelsubmit('Field \'FirstName\' cannot contain spaces.',xlaAFPform.FirstName)}}
if (xlaAFPform.LastName){if (xlaAFPform.LastName.value==''){return cancelsubmit('Field \'LastName\' is required',xlaAFPform.LastName)}if (!isAlphabetic(xlaAFPform.LastName.value)){return cancelsubmit('Field \'LastName\' can only contain alphabetic characters.',xlaAFPform.LastName)}if (xlaAFPform.LastName.value.length>15){return cancelsubmit('Field \'LastName\' cannot contain more than 15 characters.',xlaAFPform.LastName)}if (xlaAFPform.LastName.value.length<2){return cancelsubmit('Field \'LastName\' cannot contain less than 2 characters.',xlaAFPform.LastName)}if (!noSpaces(xlaAFPform.LastName.value)){return cancelsubmit('Field \'LastName\' cannot contain spaces.',xlaAFPform.LastName)}}
if (xlaAFPform.PhoneHome){if (xlaAFPform.PhoneHome.value==''){return cancelsubmit('Field \'PhoneHome\' is required',xlaAFPform.PhoneHome)}if (xlaAFPform.PhoneHome.value.length>20){return cancelsubmit('Field \'PhoneHome\' cannot contain more than 20 characters.',xlaAFPform.PhoneHome)}}
if (xlaAFPform.PhoneWork){if (xlaAFPform.PhoneWork.value.length>20){return cancelsubmit('Field \'PhoneWork\' cannot contain more than 20 characters.',xlaAFPform.PhoneWork)}}
if (xlaAFPform.PhoneCell){if (xlaAFPform.PhoneCell.value.length>20){return cancelsubmit('Field \'PhoneCell\' cannot contain more than 20 characters.',xlaAFPform.PhoneCell)}}
if (xlaAFPform.Address){if (xlaAFPform.Address.value==''){return cancelsubmit('Field \'Address\' is required',xlaAFPform.Address)}if (xlaAFPform.Address.value.length>35){return cancelsubmit('Field \'Address\' cannot contain more than 35 characters.',xlaAFPform.Address)}}
if (xlaAFPform.City){if (xlaAFPform.City.value==''){return cancelsubmit('Field \'City\' is required',xlaAFPform.City)}if (!isAlphabetic(xlaAFPform.City.value)){return cancelsubmit('Field \'City\' can only contain alphabetic characters.',xlaAFPform.City)}if (xlaAFPform.City.value.length>25){return cancelsubmit('Field \'City\' cannot contain more than 25 characters.',xlaAFPform.City)}}
if (xlaAFPform.State){if (xlaAFPform.State.value==''){return cancelsubmit('Field \'State\' is required',xlaAFPform.State)}if (!isAlphabetic(xlaAFPform.State.value)){return cancelsubmit('Field \'State\' can only contain alphabetic characters.',xlaAFPform.State)}if (xlaAFPform.State.value.length>25){return cancelsubmit('Field \'State\' cannot contain more than 25 characters.',xlaAFPform.State)}}
if (xlaAFPform.zip){if (xlaAFPform.zip.value==''){return cancelsubmit('Field \'zip\' is required',xlaAFPform.zip)}if (!isNumeric(xlaAFPform.zip.value)){return cancelsubmit('Field \'zip\' is not numeric',xlaAFPform.zip)}if (xlaAFPform.zip.value.length>6){return cancelsubmit('Field \'zip\' cannot contain more than 6 characters.',xlaAFPform.zip)}if (!noSpaces(xlaAFPform.zip.value)){return cancelsubmit('Field \'zip\' cannot contain spaces.',xlaAFPform.zip)}}
if (xlaAFPform.Email){if (xlaAFPform.Email.value==''){return cancelsubmit('Field \'Email\' is required',xlaAFPform.Email)}if (!isEmail(xlaAFPform.Email.value)){return cancelsubmit('Field \'Email\' does not contain a valid e-mail address.',xlaAFPform.Email)}if (!noSpaces(xlaAFPform.Email.value)){return cancelsubmit('Field \'Email\' cannot contain spaces.',xlaAFPform.Email)}}
if (xlaAFPform.FriendName){if (xlaAFPform.FriendName.value.length>20){return cancelsubmit('Field \'FriendName\' cannot contain more than 20 characters.',xlaAFPform.FriendName)}}
if (xlaAFPform.FriendPhone){if (xlaAFPform.FriendPhone.value.length>20){return cancelsubmit('Field \'FriendPhone\' cannot contain more than 20 characters.',xlaAFPform.FriendPhone)}}
if (xlaAFPform.FriendEmail){if (xlaAFPform.FriendEmail.value.length>40){return cancelsubmit('Field \'FriendEmail\' cannot contain more than 40 characters.',xlaAFPform.FriendEmail)}}
if (xlaAFPform.Comments){if (xlaAFPform.Comments.value.length>250){return cancelsubmit('Field \'Comments\' cannot contain more than 250 characters.',xlaAFPform.Comments)}}

}

