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

Recommended Answers

All 8 Replies

Should 10.6 become 10 or 11?

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

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

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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.