FAQ : Frequently Asked Questions
FAQ Table of contents
blue line
16. Q:  Is there any way I can ease my RPG controls on numeric input fields? How about an input date field?

A:  You may add some JavaScript to have this done. Also in this case, however, we recommend your CGI performs the appropriate checks (some Web users disable JavaScript from their browsers).

In your JavaScript evaluation you should also consider advantages ("pros") and disadvantages ("cons").

  • pro. User errors are more quickly communicated through JavaScript (it runs on the client) than through CGI response. JavaScript makes users more happy in terms of faster diagnosis.
  • con. Imbedding JavaScript in your HTML would increase the size of your page, and this might result to a slightly slower response, expecially in cases were the user connects through a slow line.
As to examples of JavaScript for controlling input fields, you may look at our page JavaScript examples: regular expressions. A little further you'll find a link (Validating form numeric fields) to a CGI performing through JavaScript exactly what you're looking for.
Should you be interested, just download and install on your AS/400 our library js2.

With regard to the checks your CGI should in any case, here are our tips:

  • If your CGI did initialize the input field, on the next "call" it might just check whether its new value is equal to initialized one. If so, the field was not changed by the user.
  • You might check numeric data through the Mel's service program chkNbr subprocedure.
    If you like to use subprocedure c2n2 instead, please note that it ignores slashes but treats dashes as minus signs.
  • Another method would be to output the date as three fields in the form: month, day, and year with separators as constants between them.
  • Another method would be to output the date twice: once in edited form ( modifiable) and once as pure numerics (as an input field).
blue line