Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:52:57+00:00 2026-06-15T14:52:57+00:00

I have some inputs on my webapp where we’re asking the user to enter

  • 0

I have some inputs on my webapp where we’re asking the user to enter percentage values (e.g 10.75%, 23%). Currently, they have to enter these values as decimal (e.g. 0.1075 , 0.23).

This is causing confusion for some users, so I was hoping there was a way I could convert the values to and from these formats (the backend has decimal values, the HTML inputs display the percentage values). Is there a solution to this without having to roll-my-own with javascript or the like?

I didn’t see anything in the HTML5 inputs that would do this, and I wasn’t able to find a javascript lib that would do it easily.

What way have other people been doing percentage inputs in HTML?


Additional Info

The webapp is using Java/Spring, so the values coming to the HTML page are coming string from the java objects in question, so ideally I’m looking for something that doesn’t take any backend coding.


Answer

It turns out that Spring 3.0 will do this automatically. Annotating the fields in question with:

@NumberFormat(style = NumberFormat.Style.PERCENT)
private BigDecimal rate;

Will do all the conversion to and from the input field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:52:58+00:00Added an answer on June 15, 2026 at 2:52 pm

    The javascript required is very simple. For example you could store the fraction value of the user’s input in a hidden field when the user submits.

    ​<form id="myForm">
        <input type="text" id="myPercent" name="myPercent" />%
        <input type="hidden" id="myFraction" name="myFraction" />
        <input type="submit" />
    </form>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    <script type="text/javascript">
        document.getElementById('myForm').onsubmit = function() {
            document.getElementById('myFraction').value = 
                document.getElementById('myPercent').value / 100;
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop a web interface allowing the user to enter some inputs
I'd like to have some hidden inputs on View A.aspx and pass the values
I have an array of user inputs ($atts) as key=>value pairs. Some of the
I have some hidden inputs like this <input name=exam.normals[1].blahblah ..../> I would like somehow
I have to escape some inputs on a form. I used mysql_real_escape_string to escape
I can't use EditorFor because my inputs have some other attributes like readonly ,
I have the following python script which takes some inputs and puts them in
I have an AngularJS page with several form inputs. When the some of the
I have a webview and I load some html5+js into it. My webapp is
Say I want to have a simple web app that takes some user input,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.