Click to See Complete Forum and Search --> : stupid if-else question


vccarvalho
10-27-2003, 10:11 AM
well, this is so stupid I'm almost ashmed of asking, but.
I have this simple function to evaluate if a value is bigger, equal or smaller than other, if it's bigger or equal no submit, else, submit: here`s the code:

function submitForm(formName) {
var minValue = document.forms[0].minValue.value;
var maxValue = document.forms[0].maxValue.value;
if(minValue > maxValue)
alert("min value cant be bigger than maxvalue");
if(minValue == maxValue)
alert("minvalue cant be equal max value");
else
alert("ok");


}

The problem is, it`s acting quite strange, for some values, it acts as expected, but others dont, like if minvalue = 6 and maxvalue = 10 it says min value is bigger, but if minvalue = 6 and maxvalue = 8, it says ok. Any suggestions?
thanx

Mr J
10-27-2003, 10:59 AM
See if this makes any difference


function submitForm(formName) {
var minValue = document.forms[0].minValue.value;
var maxValue = document.forms[0].maxValue.value;

if(minValue >= maxValue){
alert("Min value cannot be bigger or equal to maxvalue")
}
else{
alert("ok")
}

}