
// 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.first_name){if (xlaAFPform.first_name.value==''){return cancelsubmit('Field \'first name\' is required',xlaAFPform.first_name)}if (!isAlphabetic(xlaAFPform.first_name.value)){return cancelsubmit('Field \'first name\' can only contain alphabetic characters.',xlaAFPform.first_name)}}
if (xlaAFPform.last_name){if (xlaAFPform.last_name.value==''){return cancelsubmit('Field \'last name\' is required',xlaAFPform.last_name)}if (!isAlphabetic(xlaAFPform.last_name.value)){return cancelsubmit('Field \'last name\' can only contain alphabetic characters.',xlaAFPform.last_name)}}
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 (xlaAFPform.email.value.length<3){return cancelsubmit('Field \'email\' cannot contain less than 3 characters.',xlaAFPform.email)}if (!noSpaces(xlaAFPform.email.value)){return cancelsubmit('Field \'email\' cannot contain spaces.',xlaAFPform.email)}}
if (xlaAFPform.address){if (xlaAFPform.address.value==''){return cancelsubmit('Field \'address\' is required',xlaAFPform.address)}if (!isAlphanumeric(xlaAFPform.address.value)){return cancelsubmit('Field \'address\' can only contain alphanumeric characters.',xlaAFPform.address)}}
if (xlaAFPform.city){if (xlaAFPform.city.value==''){return cancelsubmit('Field \'city\' is required',xlaAFPform.city)}if (!isAlphanumeric(xlaAFPform.city.value)){return cancelsubmit('Field \'city\' can only contain alphanumeric 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>2){return cancelsubmit('Field \'state\' cannot contain more than 2 characters.',xlaAFPform.state)}}
if (xlaAFPform.zip){if (xlaAFPform.zip.value==''){return cancelsubmit('Field \'zip\' is required',xlaAFPform.zip)}if (!isAlphanumeric(xlaAFPform.zip.value)){return cancelsubmit('Field \'zip\' can only contain alphanumeric characters.',xlaAFPform.zip)}if (xlaAFPform.zip.value.length<5){return cancelsubmit('Field \'zip\' cannot contain less than 5 characters.',xlaAFPform.zip)}if (!noSpaces(xlaAFPform.zip.value)){return cancelsubmit('Field \'zip\' cannot contain spaces.',xlaAFPform.zip)}}
if (xlaAFPform.country){if (xlaAFPform.country.value==''){return cancelsubmit('Field \'country\' is required',xlaAFPform.country)}if (!isAlphabetic(xlaAFPform.country.value)){return cancelsubmit('Field \'country\' can only contain alphabetic characters.',xlaAFPform.country)}}
if (xlaAFPform.home_phone){if (xlaAFPform.home_phone.value==''){return cancelsubmit('Field \'home phone\' is required',xlaAFPform.home_phone)}if (!noSpaces(xlaAFPform.home_phone.value)){return cancelsubmit('Field \'home phone\' cannot contain spaces.',xlaAFPform.home_phone)}}
if (xlaAFPform.relocate){if (xlaAFPform.relocate.value==''){return cancelsubmit('Field \'relocate\' is required',xlaAFPform.relocate)}}
if (xlaAFPform.location_pref){if (xlaAFPform.location_pref.value==''){return cancelsubmit('Field \'location pref\' is required',xlaAFPform.location_pref)}if (!isAlphabetic(xlaAFPform.location_pref.value)){return cancelsubmit('Field \'location pref\' can only contain alphabetic characters.',xlaAFPform.location_pref)}}
if (xlaAFPform.available){if (xlaAFPform.available.value==''){return cancelsubmit('Field \'available\' is required',xlaAFPform.available)}}
if (xlaAFPform.employed){if (xlaAFPform.employed.value==''){return cancelsubmit('Field \'employed\' is required',xlaAFPform.employed)}}
if (xlaAFPform.college_degree){if (xlaAFPform.college_degree.value==''){return cancelsubmit('Field \'college degree\' is required',xlaAFPform.college_degree)}}

}

