
function validateForm(form,target){
	
	//get an array of only the required fields
	var fields = $(":input[oz_req][value='']",form).serializeArray();
	var result = true;
	
	jQuery.each(fields, function(i, field){
        //if a field is blank or null, return its custom message
        var message = $(":input[name='"+field.name+"']",form).attr("oz_label");
        
        //focus on the input
        $(":input[name='"+field.name+"']",form).focus();
        	
        //if target was passed, update that element's text with error
        if (undefined != target){
        	$(target).text(message);
        }
        //otherwise, just show an alert
        else
        {
        	alert(message);
        }
		
   		result = false;
      	return false;
	    
	});
	    
    return result;
}


function validateField(field,form,message,target){
	
	// field = ID of single input field to validate
	
	var result = true;
	
	//var thisValue = $("#"+field+":visible[value='']",form).length;
	//alert(thisValue);
	
	if ($("#"+field+":visible[value='']",form).length > 0){
		
		//if a field is blank or null, return its custom message
		
		//focus on the input
		$("#" + field, form).focus();
        	
		//if target was passed, update that element's text with error
		if (undefined != target){
			$(target).text(message);
		}
		//otherwise, just show an alert
		else
		{
			alert(message);
		}
			
   		result = false;
		return false;
	}
	
	//return false;
	    
    return result;
}


