Tags:
create new tag
view all tags

SID-02412: Numeric Only - Form Field Template Element

Status: Answered Answered TWiki version: 6.1.0 Perl version: Perl 5.30.0
Category: CategoryForms Server OS: linux (Kernel version: 2.6.32-754.15.3.el6.x86_64) Last update: 5 years ago

Is there currently a way (or is one coming/proposed) to have a Numeric Only Form Field Type. One that would either restrict the file to numbers only --or-- numbers plus associated characters like a plus sign (+), minus sign (-), a decimal point (.) and a comma (,).

At this time, we have a form that asks for "Number of Days," for which we want only numeric values. For some reason, people enter values like "1.5 days" or "22 days", instead of just 1.5 or 22 respectively. No matter how much training we give them and how many reminders we send out, we still get non-numeric input.

Any help would be appreciated. Thanks.

-- Bob Mellinger - 2019-08-06

Discussion and Answer

As far as I can say, TWiki's own type system does not allow to restrict text input (and new releases don't come that often), so I can only suggest workarounds:

  • HTML itself allows to restrict the values of input fields with input type="number". I usually write my own HTML forms for applications, so this is often the way I go.
  • JavaScript validation could either reject the non-numeric stuff or silently drop it.
  • The TWiki stuff evaluating the field might also be able to strip units, maybe even automagically, given that in Perl the numeric value of "22 days" is just 22.

-- Harald Jörg - 2019-08-10

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Numeric Only - Form Field Template Element
SupportCategory CategoryForms
TWiki version 6.1.0
Server OS linux (Kernel version: 2.6.32-754.15.3.el6.x86_64)
Web server Apache: 2.4.39
Perl version Perl 5.30.0
Browser & version Firefox 68.0.1
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2020-06-11 - BobMellinger
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.