Forms

A form is a way to get something from the reader: a news subscription, a request, a callback order. The reader fills in the fields and presses the button, and then a script takes over: it accepts the data, does something with it and answers the page.

Form fields

A form is assembled from fields of different types:

  • Text — one line: a name, a company, the subject of a request.
  • Number — digits only: a quantity, an amount, a year.
  • Email — an email address with a format check.
  • Password — typed with hidden characters.
  • Multi-line text — for comments and descriptions.
  • A choice from a list — the reader picks one option from ready ones.
  • Checkbox — a consent or a confirmation: “I agree to data processing”, for example.
  • Date — a date picked from a calendar.
  • Hidden field — invisible to the reader, but its value travels with the submission. That is how service marks are added to a form: where the request came from, which page it was.

The check before sending

Required fields are checked before submission, right in the browser. When something is missing or the email is typed wrong, the reader sees a hint and stays in place — the entered values are not lost. A checkbox is required only when it is marked as such.

What the script’s answer does

After submission the script can answer the page in different ways:

  • a message — a toast: about success, an error, or information;
  • a refresh of blocks — part of the page recomputes with the new data; a subscriber counter grows, for example;
  • a redirect — another portal page or an external address opens, a thank-you page say;
  • a file download — the reader at once receives a file the script assembled.

When the script returns a soft error

Sometimes the data is formally filled in but does not fit: that email is already subscribed, or the code does not exist. In that case the script returns a soft error, and its text shows right under the form — the reader sees what to fix, and every entered value stays in place. The form does not have to be typed again.

Confirmation and double-click protection

A confirmation question can be set before submission — “Submit the request?”, for example. While the submission is in flight, the button shows that work is going on and cannot be pressed again: no double request will go out. The public site also has the shared protection from frequent submissions — at most ten per minute from one address.

Example: a news subscription

The demonstration portal has a subscription form: name and email. After submission a success message appears, and the subscriber-counter block on the same page refreshes and shows the new number. The form clears and is ready for the next subscription. That is the full working circle: filled in — sent — saw the result on the page.

Next: how the agent edits content — in the Agent Management section; how a form’s data is computed — in Scripts & Dependencies; how to open a form to the outside — in Public Site.

← Back to the documentation index