Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is 25 greater than 180? 2

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
I am using JS to validate and make sure users do not enter values greater than expected or allowed.

I am having problem with this. Where the maximum allowed is 180, if one enter a number like 25, my existing logic says that 25 is greater than 180.

I figure it is doing an alpha comparison and of course, 2 is greater than 1. I need this to be numeric.

How do I solve this?

Thanks!
 
How do I solve this?

Do a google search for parseInt or parseFloat

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
parseInt(String) will return an integer from a string.

_________________
Bob Rashkin
 
Great guys!

Is there a cheat sheet or cheat page where one could reference these?

Regards,
 
I use devguru as a reference a lot:


-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top