Javascript number field comparison

HI All I am comparing two number field using javascript on web , but its not comparing correcly

for example region from value is 7 and region to value is 28 then its comparing wrongly

am using below code any idea please

if ((thisForm.RegionFr.value!=“”) && (thisForm.RegionTo.value !=“”)){

if (( thisForm.RegionFr.value ) > (thisForm.RegionTo.value)){

	alert("Region To Code Should be greater than Region From Code");

	return false;

	}



}

return true;

}

thanks

soma

Subject: Take a look at JavaScript isNaN

Right now you are just checking if the field is empty, you want to check it’s a number.

Subject: javascript number

Hi Thanks for your reply, i am entering number only and also am validting to enter only the number . but its not comparing correcly

Subject: Is this your actual code?

If it is there you have too many }

if ((thisForm.RegionFr.value!=“”) && (thisForm.RegionTo.value !=“”)){

if (( thisForm.RegionFr.value ) > (thisForm.RegionTo.value)){

	alert("Region To Code Should be greater than Region From Code");

	return false;

	}



}

return true;

}

Also you need to wrap your values in either parseInt or parseFloat as form input fields are always treated as text in HTML/Javascript

example:

if (parseInt(thisForm.RegionFr.value) > parseInt(thisForm.RegionTo.value)){

Subject: still the same problem

Hi I removed the extra } then also same problem

	if ((thisForm.RegionFr.value!="") && (thisForm.RegionTo.value !="")){



if (thisForm.RegionFr.value > thisForm.RegionTo.value){

	alert("Region To Code Should be greater than Region From Code");

	return false;

	}



}

thanks a lot

soma

Subject: This works for me