Hi everyone,
The function I've got works perfectly but the problem is that it displays the message quickly and then the message disappears for some reason. Am I doing something wrong??
function validateForm(){
var input0 = document.getElementById('input0').value;
var input1 = document.getElementById('input1').value;
var input2 = document.getElementById('input2').value;
var input3 = document.getElementById('input3').value;
var input4 = document.getElementById('input4').value;
var input5 = document.getElementById('input5').value;
var input6 = document.getElementById('input6').value;
var input7 = document.getElementById('input7').value;
var input8 = document.getElementById('input8').value;
var input9 = document.getElementById('input9').value;
var input10 = document.getElementById('input10').value;
// initialise a variable with a value == 0
var total = 0;
var message = document.getElementById('message');
var totalPara = document.getElementById('total');
var inputValues = new Array(input0, input1, input2, input3, input4, input5, input6, input7, input8, input9, input10);
var elem;
for(elem=0; elem<= inputValues.length; elem++){
if(inputValues[elem] < 0 ){
message.innerHTML = " Error: The input can't be LESS than ZERO! ";
message.style.backgroundColor="red";
message.style.width="300px";
return false;
}else if(inputValues[elem] > 35){
message.innerHTML = " Error: The input can't be GREATER than 35! ";
message.style.backgroundColor="red";
message.style.width="300px";
}
}
}
Any idea of what is wrong with this?