Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Bucharest, ROMANIA
    Thanked 379 Times in 375 Posts
    According to your latest code, you don't even validate for humidity & rainfall. All I can see is a validation for "temperature_max" and "temperature_max", which appear to work.

    Offshore programming

  2. #17
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,573 Times in 2,551 Posts
    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:-

    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:-

    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?
    Last edited by Philip M; 04-12-2010 at 01:19 PM.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts