Start New Discussion Reply to this Discussion values not comparing
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');
}
else
{
}
}
</script>
Regards//
Related Article: assigning dynamic values
is a JavaScript / DHTML / AJAX discussion thread by ratanji that has 1 reply, was last updated 10 months ago and has been tagged with the keywords: dynamic, values.
Farhad.idrees
Junior Poster
102 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
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.
AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 25
Farhad.idrees
Junior Poster
102 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
<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?
Farhad.idrees
Junior Poster
102 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
Sorry, I didn't understand what you want. Please rephrase it.
AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 25
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?
regards
Farhad.idrees
Junior Poster
102 posts since Dec 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0
You can do it like this:
var input = document.getElementById('myInputID');
var className = input.className;
input.className = className.replace("int[5]", "int[7]");
AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 25
© 2013 DaniWeb® LLC
Page generated in 0.0782 seconds
using 2.67MB