Question T4531
Visible to All Users

Input Precision Validation

created 5 years ago

Hello,

Please could you advise if the standard input validation for a number can check precision and scale or will I need a custom widget?

Kind regards
Chris

Answers approved by surveyjs Support

created 5 years ago

Hello,

Some time ago we decided not to waste time writing our mask control. You can use Inputmask custom widget for this

Thanks, Alex
SurveyJS Team

    Show previous comments (11)

      Hi Serge,

      Thank you for your response.

      Yes, I did try the input masks 9.9_ and 9.90 but they don’t seem to do what my client is wanting.

      Both input masks 9.9_ and 9.90 only allows me to enter the first decimal place and I ought to be able to enter no decimal places, one or two decimal places (e.g. 7, 7.2 or 7.25 but no more).

      This would be similar to the REGEX pattern [0-9]?(\.[0-9][0-9]?)?`````` ``````Kind regards``````Chris

        Hello,

        You can use "9.9{0,2}" for this. Here is live sample in plunker. Please, read Inputmask documentation and advices on the forums for more information

        Thanks, Alex
        SurveyJS Team

          Hello,

          Here is the Inputmask documentation - https://github.com/RobinHerbots/Inputmask

          Thanks, Serge
          SurveyJS Team