I'm using javascript to do the same (validate a form with upladed files), i hope it will be convient to what you want to do
$(document).ready(function() {
$(".verif_form_ajax").submit(function(){
var $inscription_form = $('#inscription_form');
var process;
process=1;
$(".obg").each(function(){
var length = $(this).val();
if(length==""){
$(this).css('border-color','#c89494');
$(this).css('background-color','#F9D3D3');
process=0;
}else{
$(this).css('border-color','#9ac894');
$(this).css('background-color','#dbfcd7');
}
});
$(".obg").blur(function(){
var length = $(this).val();
if(length==""){
$(this).css('border-color','#c89494');
$(this).css('background-color','#F9D3D3');
process=0;
}else{
$(this).css('border-color','#9ac894');
$(this).css('background-color','#dbfcd7');
}
});
if(process=="0"){
return false;
}
else{
file = $('#userfile').val();
contentType:attr( "enctype", "multipart/form-data" ),
$.post($(this).attr("action"), {file:file}, $(this).serialize(), function(data){
// do wathever you want to do when form is posted
$inscription_form.html(data);
});
return false;
}
});
});
then in the form whetever you want a validate filed you put it a class ="obg" like this
<label>Namen :</label>
<input class="obg" type="text" placeholder="Your name" name="denomination" id="denomination" >
PS : please excuse my poor English!!