Pego el código.
Código:
  
function comprueba()
{
	var fecha=/^([0]?[1-9]|[1-2][0-9]|[3][0-1])-([0]?[1-9]|[1][0-2])-\d{4}$/;
	var hora=/^([0?]9:[0-5][0-9]|1[0-9]:[0-5][0-9]|20:[0-5][0-9]|21:00)$/;
				
if(!fecha.test(document.getElementById("fechaSolicitada").value))
	{
		alert("Debes escribir unha data de solicitude correcta (dd-mm-aaaa)");
		document.f.fechaSolicitada.focus();
		return false; 
	}
				if(!hora.test(document.getElementById("horaSolicitada").value))
	{
		alert("Debes escribir unha hora de solicitude correcta (hh:mm)");
		document.f.horaSolicitada.focus();
		return false;
	}
if (!fecha.test(document.getElementById("fechaDevolucion").value))
	{ 
	        alert("Debes escribir unha data de devolución correcta (dd-mm-aaaa)");
		document.f.fechaDevolucion.focus();
		return false; 
        }
				if(!hora.test(document.getElementById("horaDevolucion").value))
	{
		alert("Debes escribir unha hora de devolución correcta (hh:mm)");
		document.f.horaDevolucion.focus();
		return false;
	}
return true;
}
Código PHP:
   <form name="f" action="insertar_prestamos.php" method="post" onSubmit="return comprueba();">
                        <label>DATA SOLICITADA</label><img src="jpg/interrogacion.jpg" title="FORMATO[DD-MM-AAAA]" width="15" height="15"/>
                        <input type="text" id="fechaSolicitada" name="fechaSolicitada" size="15">
                        <label>HORA SOLICITADA</label><img src="jpg/interrogacion.jpg" title="FORMATO[HH:MM]" width="15" height="15"/>
                        <input type="text" id="horaSolicitada" name="horaSolicitada" size="15"><br/>
                        <label>DATA DEVOLUCIÓN</label><img src="jpg/interrogacion.jpg" title="FORMATO[DD-MM-AAAA]" width="15" height="15"/>
                        <input type="text" id="fechaDevolucion" name="fechaDevolucion" size="15">
                        <label>HORA DEVOLUCIÓN</label><img src="jpg/interrogacion.jpg" title="FORMATO[HH:MM]" width="15" height="15"/>
                        <input type="text" id="horaDevolucion" name="horaDevolucion" size="15">
                        <input type="submit" value="Filtrar" name="enviar">
                    </form> 
     
 


