Ya lo he resuelto, os dejo el resultado, por si a alguien le hace falta ;)
Código Javascript
:
Ver original<script language="javascript">
function Right(str, n)
/***
IN: str - the string we are RIGHTing
n - the number of characters we want to return
RETVAL: n characters from the right side of the string
***/
{
if (n <= 0) // Invalid bound, return blank string
return "";
else if (n > String(str).length) // Invalid bound, return
return str; // entire string
else { // Valid bound, return appropriate substring
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
</script>
<script language="javascript">
function validar(frm) {
var ret;
var txt;
var txt2;
txt = Right(frm.fichero.value,3);
txt2 = Right(frm.fichero2.value,3);
if (txt != "pdf"){
alert('Por favor, el primer archivo debe ser .pdf');
ret = false;
}
if (txt2 != "doc"){
alert('Por favor, el segundo archivo debe ser .doc');
ret = false;
}
if (frm.firma.value == "" ) {
alert('Por favor, seleccione si quiere firmar el informe o no');
ret = false;
}
return ret;
}
</script>
La primera función saca N caracteres de una cadena dada. A partir de ahí saco los tres últimos de ambos campos file y compruebo que sean pdf y doc respectivamente. Si se cumple, sigue adelante, sino, avisa al usuario ;)