954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Remove decimal from input textbox

Hi Everyone,
I have a requirement of formatting the text inside the input text box. On page load, the textbox value by default get set to say 10.0 or 15.0. What I want is just integer and remove the decimal point and the values ahead.

Thanks in Advance.

Regards
JJ

jatin.jain
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Should 10.6 become 10 or 11?

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

10.0-> 10

jatin.jain
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Yes, but should non-integers be rounded or floor'd? If rounded, use Math.round(element.value) , if not, use parseInt(element.value) .

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

I want to achieve this using only css. No javascript. only css. Is that possible ?

jatin.jain
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Nope. You can't alter an input value from CSS.

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

there is something cal l@decimal-format / number-format in css. But somehow its not working.

jatin.jain
Newbie Poster
4 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

Yes, but that applies to the content, not the value of an element.

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

Can you post the code of the input element, and the css you have tried?

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: