• Post Reply Bookmark Topic Watch Topic
  • New Topic

comparing numeric field values  RSS feed

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I have to write a javascript code wherein , if the amount is greater than 500 and less than or equal to 50000 only then accepted. Here i have written the code for it, still it shows  " amount accepted"  for any value .why  so




 
Author and ninkuma
Marshal
Posts: 66346
155
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: fields values are always strings.

Hint: "amt" is lazy. Why isn't the name "amount"?
 
Sheriff
Posts: 22955
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if numeric comparisons were being done, it would still always print "amount accepted".

Suppose amount is 0. Then since it's <= 50000, it's accepted. Suppose it's 1000000. Then since it's >= 500, it's accepted. No matter what you try, it's either >= 500 or it's <= 50000. I expect the real requirement was for it to be >= 500 AND <= 50000.
 
Paul Clapham
Sheriff
Posts: 22955
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:I expect the real requirement was for it to be >= 500 AND <= 50000.



Now that I read the original post, that is in fact the real requirement. Sorry for not reading it completely the first time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!