Apart from
is_leaf_fresh = -1;
for (i=0;i < thisform.
is_leaf_fresh.length; i++)
which is bound to give trouble in some browsers. Use this instead:-
Code:
ilf = false;
for (i=0;i < thisform.is_leaf_fresh.length; i++) {
if (thisform.is_leaf_fresh[i].checked == true) {
ilf = true;
}
if (!ilf) {
alert("You must select an option for Fresh Leaf!");
return false;
}
You have
var numericExpression = /^[0-9]+$/;
if(temp_max.match(numericExpression) && (temp_max>=0 && temp_max<=50)){
return true;
which does exactly that, returns true and submits the form. As "true" is the default it is strictly speaking never necessary to have
return true in a form validation. If you do, it should occur only once - right at the end.
Suggest you use something like this:-
Code:
var temp_max = document.getElementById("temperature_max").value; // allows decimal values
// OR var temp_max = parseInt(document.getElementById("temperature_max",10).value); // if only whole numbers are allowed
if ((isNaN(temp_max)) || (!temp_max) || (temp_max <0) || (temp_max >50)) {
alert("Max Temperature value should be Numeric & between 0 to 50");
document.getElementById("temperature_max").value = ""; // clear the field
myfield = document.getElementById("temperature_max"); // note myfield must be a global variable
setTimeout('myfield.focus();myfield.select();' , 10); // refocus on the field - overcome bug in Firefox
return false;
}
There seems to be no validation at all for humidity and rainfall.
Why are you not using Firebug as suggested?