
// 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.Patients_Name){if (xlaAFPform.Patients_Name.value==''){return cancelsubmit('Field \'Patients Name\' is required',xlaAFPform.Patients_Name)}if (xlaAFPform.Patients_Name.value.length>50){return cancelsubmit('Field \'Patients Name\' cannot contain more than 50 characters.',xlaAFPform.Patients_Name)}}
if (xlaAFPform.Parent_Name){if (xlaAFPform.Parent_Name.value.length>50){return cancelsubmit('Field \'Parent Name\' cannot contain more than 50 characters.',xlaAFPform.Parent_Name)}}
if (xlaAFPform.Primary_Phone){if (xlaAFPform.Primary_Phone.value==''){return cancelsubmit('Field \'Primary Phone\' is required',xlaAFPform.Primary_Phone)}if (xlaAFPform.Primary_Phone.value.length>20){return cancelsubmit('Field \'Primary Phone\' cannot contain more than 20 characters.',xlaAFPform.Primary_Phone)}}
if (xlaAFPform.Preferred_Dates_Times){if (xlaAFPform.Preferred_Dates_Times.value.length>400){return cancelsubmit('Field \'Preferred Dates Times\' cannot contain more than 400 characters.',xlaAFPform.Preferred_Dates_Times)}}
if (xlaAFPform.Alternate_Phone){if (xlaAFPform.Alternate_Phone.value.length>20){return cancelsubmit('Field \'Alternate Phone\' cannot contain more than 20 characters.',xlaAFPform.Alternate_Phone)}}
if (xlaAFPform.CODE){if (xlaAFPform.CODE.value==''){return cancelsubmit('Field \'CODE\' is required',xlaAFPform.CODE)}if (xlaAFPform.CODE.value.length>7){return cancelsubmit('Field \'CODE\' cannot contain more than 7 characters.',xlaAFPform.CODE)}if (xlaAFPform.CODE.value.length<7){return cancelsubmit('Field \'CODE\' cannot contain less than 7 characters.',xlaAFPform.CODE)}}
if (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>50){return cancelsubmit('Field \'Email\' cannot contain more than 50 characters.',xlaAFPform.Email)}}

}

