Hector Minaya
Hector Minaya

Reputation: 1705

jQuery rounding problem with .val()

I have a textbox where a user inputs a number, like: 105.14 When I use jQuery to read it:

alert(parseInt($("#Info").val()));

It displays "105".

Why can't I get the remaining .14????

I'm sure it's something obvious....

Upvotes: 0

Views: 206

Answers (1)

Corey Ballou
Corey Ballou

Reputation: 43457

This is because you are using parseInt(), which is rounding.

Try parseFloat() instead.

Upvotes: 10

Related Questions