visionweb
07-31-2010, 02:40 PM
I am trouble in comparing decimal number.
var1 = 0.25
var2 = 0.50
if (var1<var2)
{
alert("Value is less than minimum")
}
else
{
return true;
}
How can I make it work. Thanks for help in advance
jmrker
07-31-2010, 04:17 PM
I am trouble in comparing decimal number.
var1 = 0.25
var2 = 0.50
if (var1<var2)
{
alert("Value is less than minimum")
}
else
{
return true;
}
How can I make it work. Thanks for help in advance
If you just trying to get the alert to display, do this:
if (var2 < var1)
...
Philip M
07-31-2010, 04:30 PM
A return statement must be within a function.
<script type = "text/javascript">
function myFunction() {
var1 = 0.25
var2 = 0.50
if (var1<var2) {
alert("Value is less than minimum");
return false;
}
else {
return true;
}
}
myFunction(); // to run the function
</script>
It is a bad idea for obvious reasons to name variables var1 and var2.