Is it possible to force percentages with two decimal points?

0

I’m using a textbox grid question type. The percent validation answer format seems to allow respondents to enter whole numbers (e.g. 1%) as well as decimals (e.g. 0.25%). I’ve been asked to have the validation be a percent and have two decimal points. As an illustration, some possible example answers would be:

  • 0.25%
  • 1.25%
  • 1.00%
  • 80.25%

And so on.

I can’t see an option to force the number of decimal points. Anyway to force two decimal points (even if they are .00)?

Thanks!

McGladrey National answered
    0
    IS 2.20K Rep.

    I haven’t tested this, but if you use RegEx validation, the following RegEx pattern should¬†work:

    <code><span class="pun">^</span><span class="lit">0</span><span class="pun">*(</span><span class="lit">100</span><span class="pln">\.</span><span class="lit">00</span><span class="pun">|[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]?[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]</span><span class="pln">\.</span><span class="pun">[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]{</span><span class="lit">2</span><span class="pun">})%</span><span class="pln">$<br /><br /></span></code>it breaks down as:<br />^0*  = starts with any number of leading zeros (including none)<br />(  = start a grouping. This is used here to group the two things seperated by the "or" <br />100\.00  = match exactly 100.00<br />|  = or<br />[0-9]?  = zero or one occurrences of a character between 0 and 9<br />[0-9]\. = a character between 0 and 9 followed by a period<br />[0-9]{2} = exactly 2 occurrences of any character between 0 and 9<br />)  = end the grouping for the "or"<br />%$  = ends with a percent sign<br /><br />The following percentage strings will NOT match:<br />.10%  (must have a character before the period)<br />99.00  (must have the percent sign)<br /><br />The RegEx could be altered if you wanted the above two example to work to something like:
    <code><span class="pun">^</span><span class="lit">0</span><span class="pun">*(</span><span class="lit">100</span><span class="pln">\.</span><span class="lit">00</span><span class="pun">|[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]?[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]?</span><span class="pln">\.</span><span class="pun">[</span><span class="lit">0</span><span class="pun">-</span><span class="lit">9</span><span class="pun">]{</span><span class="lit">2</span><span class="pun">})%?</span><span class="pln">$<br /><br /></span></code>
    IS commented
      • Ack, I don’t know what I did to cause my post to be formatted that way. I will see if I can figure out how to post this info better.

      0

      Thanks! It doesn’t seem to be working the way I had hoped but I appreciate your response.

      McGladrey National answered
        1
        IS 2.20K Rep.

        Well, I couldn’t figure out how to get my post past the AnsPress filter, so here is an image of what I meant to send:

        IS answered
          ×

          Login

          Question stats

          • Active
          • Views623 times
          • Answers3 answers
          • Followers1 follower