HI i have to compare three values but its not working..

alert box is not showing if i m putting less or greater values...i m calling this function on blur...

function validate(value) 

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

      // alert(value);

      if( value < mimimum )

         alert('Value is less than minimum value');


      else if(value > maximum )
          alert('Value is greater than maximum value');





Recommended Answers

All 6 Replies

I think your want to make int comparisson, if sou use parseInt(document.getElementById('min').innerText). If it's float, use parseFloat().

Using > and < with string will not do you any good.

yes Sir working..

<input value="-7" class="validate[required,custom[integer],min[5]] text-input" type="text" name="min" id="min" />

here is one more problem..
i wanto use my javascript varible value in above class "validate[required,custom[integer],min[5]]" here like use dynamic number where 5 is using how to do it?

Sorry, I didn't understand what you want. Please rephrase it.

i m getting value from java script..
now i want to use that particular value in input element class
<input value="-7" class="validate[required,custom[integer],min[5]] text-input" type="text" name="min" id="min" />

u can see min[5] i want to use javascript value in min[javascript varible value]

how to do it?

You can do it like this:

var input = document.getElementById('myInputID');
var className = input.className;

input.className = className.replace("int[5]", "int[7]");
Be a part of the DaniWeb community

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