Hola otra vez,
He seguido probando y probando y ya he dado con el tema. Así que muchas gracias, pero ya no teneis que molestaros.
De todas maneras incluyo la solución por si le sirve a alguien:
Código PHP:
function ValidateForm()
{
var wrong=false;
with (document.InputForm)
{
number = elements.length;
for (a = 0; a < number -2 ; a++)
{
if (elements[a].disabled == false)
{
if (elements[a].type == 'text')
{
// (/ /g, '') es una expresion regular para buscar espacios y substituirlos por ''
if ((elements[a].value.replace(/ /g, '') == '') || (isNaN(elements[a].value)))
{
elements[a].style.backgroundColor = "#ffffcc";
wrong= true;
}
else
elements[a].style.backgroundColor = "white";
}
}
if (elements[a].disabled == true)
{
if (elements[a].style.backgroundColor = "#ffffcc")
elements[a].style.backgroundColor = "white";
}
}
if (wrong)
alert("Some mandatory data are missing or wrong. Please, check and fill the coloured fields before starting the simulation");
else
submit();
}
}
Este script valida campos vacíos, con espacios en blanco y campos numéricos.
Un saludo,
Carlos.