
// Absolute Form Processor .NET : Form Validation System
// Copyright(c)XIGLA SOFTWARE
// http://www.xigla.com

function cancelsubmit(msg,element){
	alert(msg);
	document.getElementById(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 (xlaAFPexists('first_name')){
    if (xlaAFPget('first_name').value==''){return cancelsubmit('Field \'first name\' is required','first_name')}

}

if (xlaAFPexists('last_name')){
    if (xlaAFPget('last_name').value==''){return cancelsubmit('Field \'last name\' is required','last_name')}

}

if (xlaAFPexists('patient_account')){
    if (xlaAFPget('patient_account').value==''){return cancelsubmit('Field \'patient account\' is required','patient_account')}

}

if (xlaAFPexists('day_tel')){
    if (xlaAFPget('day_tel').value==''){return cancelsubmit('Field \'day tel\' is required','day_tel')}

}

if (xlaAFPexists('evening_tel')){
    if (xlaAFPget('evening_tel').value==''){return cancelsubmit('Field \'evening tel\' is required','evening_tel')}

}

if (xlaAFPexists('email')){
    if (!isEmail(xlaAFPget('email').value)){return cancelsubmit('Field \'email\' does not contain a valid e-mail address.','email')}

}

if (xlaAFPexists('doctor_name')){
    if (xlaAFPget('doctor_name').value==''){return cancelsubmit('Field \'doctor name\' is required','doctor_name')}

}

if (xlaAFPexists('comments')){
    if (xlaAFPget('comments').value==''){return cancelsubmit('Field \'comments\' is required','comments')}

}


}

function xlaAFPget(what){
	return(document.getElementById(what));
}

function xlaAFPexists(what){
	if (document.getElementById(what))
		return true;
	else 
		return false;

}

