Hi i m checking my values from javascript functiions..i m comparing values...
alert is showing that values are not euqal but
but form is still submitting.....when i press submit....

java script code is

<script type="text/javascript">

 function validate(value) 
    {


        var minimum = document.getElementById('min').innerText;
        var maximum = document.getElementById('max').innerText;
        var mini = parseInt(minimum);
        var maxi = parseInt(maximum);



      if( value < mini )
      {

         alert('Value is less than minum value');
         return false;

      }

      else if(value > maxi)
      {
          alert('Value is greater than maximum value');
          return false;
      }
      else
      {
           return true;
      }

    }

 </script>

my form is

i m calling above function on form submitting

onsubmit="return validate();

what should i do?
Regards..
Farhad

Is it possible that your if..else is always just resulting in the last else block and that's why it's submitting? You can put in some console.log()s to check the values?

hai Farhad.idrees,

i think you haven't passed any value to validate(some_value) . i dont know exactly whether that 'value' varible may takes default value for comparing .

as JorgeM said , the above reason might be the one .so make that if..else statements properly

one more thing
at line 7 and 8:

var minimum = document.getElementById('min').innerText

there is no innerText propety for an html element in javascript. you may use innerHTML for accessing data from label,div,span elements only

check those once

letme know the status

happy coding

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.