Short text with regex validation

Custom field ::: customfield_textregex
Maintained by Bence Molnar
Textregex customfield plugin allows to have a short text input field with regex validation. Enabling to ensure a valid format of the field data.
Latest release:
34 sites
22 downloads
1 fans
Current versions available: 1

Moodle Shorttext customfield with regex validation

Build Status Releasing in the Plugins directory

Textregex customfield plugin allows to have a short text input field with regex validation. Enabling to ensure a valid format of the field data.

Setting up the field

A Perl-compatible regular expression is used to validate the user input. Regex can be defined during the creation of the field itself, e.g., a course custom field. Because the regex definition might be challenging, we recommend using this plugin only if you can restrict the new field definitions to expert users. The plugin performs a regex validation on the server side when saving the field. Please add a detailed description for the field that explains the rules in a human-readable form, as most of the users will not understand the regex and, therefore, will be unable to correct their input unless you have a good description. For multi-language sites, currently, the only way to provide a translated description is to use a multilang filter on the site and provide a description in all used languages in the description field.

Entering data to a field

Once the field is defined, users can use it like a regular text field. Enter data and store it. If the entered value does not match the regex, input will not be accepted, and the user will receive a standard notification, including the regex. Field data validation is performed on both the server and client sides.

Course fields

This plugin cannot be used as a user profile field. If you want to add regex validated fields to user profiles, please use https://moodle.org/plugins/profilefield_textregex plugin instead.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4

Contributors

Bence Molnar (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Plugins bot
    Wed, 22 May 2024, 12:30 PM
    Approval issue created: CONTRIB-9581
  • Gimena Natalia Motto
    Mon, 21 Oct 2024, 3:23 PM
    Thank you very much for the plugin! a query: we will use it for data that is very important for reports, necessary to be validated and this makes it much easier. But the question arises since it is a type of field, if deleting the field or wanting to change it to a text one is possible or are the records deleted? I hope to explain my query... Or I pose another different situation, what happens if the plugin is deleted by mistake, for example... those fields created therefore disappear, the data from previous reports or it is changed to another type of field ..
  • Bence Molnar
    Mon, 21 Oct 2024, 5:29 PM
    Hi Gimena,
    This behavior is defined by the Moodle environment. Therefore, I have no influence on that. In general, we can say that there is no field conversation between types, so if you switch types or delete one type, your data will most probably lost.
  • Bence Molnar
    Wed, 5 Feb 2025, 2:44 AM
    Hi Gimena,
    I have created the user profile field version of the plugin, it is waiting for approval, but you can find the repository here: https://github.com/benyovszky/moodle-profilefield_textregex
Please login to post comments