Moodle
  1. Moodle
  2. MDL-12619

Custom User Profile Fields - Add ability to define an input mask for data validation

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Administration
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      1940

      Description

      This question has been raised in response to the birthday block; however, I think it has utility regardless of use as it would allow for user's to be forced to input valid data. Using some type of input mask for data validation would be helpful. I'm thinking along the lines of:

      Date (ISO, USA, EUR)

      1. for a digit
        a for lower case alpha
        A for upper case alpha
        @ for alphanumeric
        All other characters would be literal

      Hence a mask for a U.S. phone number could be (###) ###-####

      That way if a Moodle administrator wanted to enforce that the data be entered properly they would have a tool by which to do it. AFAIK, since the data is simply stored as text there is currently no way of validating. The user's of the birthday block would like the users to input a birthday; however, they have no way of enforcing that the user input a valid date.

      Peace - Anthony

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          I would personally prefer regex there, we already have this type of validation in admin settings.

          Show
          Petr Škoda added a comment - I would personally prefer regex there, we already have this type of validation in admin settings.
          Hide
          Anthony Borrow added a comment -

          Skodak - Regex makes more sense then masks as it strikes me as more consistent with Moodle practices.

          Show
          Anthony Borrow added a comment - Skodak - Regex makes more sense then masks as it strikes me as more consistent with Moodle practices.
          Hide
          Anthony Borrow added a comment -

          As I have been looking at the database activity module code, it handles data validation and offers a variety of field types. I think it would be worth looking in to bringing those same field types in to the custom user profile types. Peace - Anthony

          Show
          Anthony Borrow added a comment - As I have been looking at the database activity module code, it handles data validation and offers a variety of field types. I think it would be worth looking in to bringing those same field types in to the custom user profile types. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Just to be specific: checkbox, date, file, latlong, menu, multimenu, number, picture, radiobutton, text, textarea, and url. I also like the possibility that an additional field type could be added as a plugin to provide that validation. Peace - Anthony

          Show
          Anthony Borrow added a comment - Just to be specific: checkbox, date, file, latlong, menu, multimenu, number, picture, radiobutton, text, textarea, and url. I also like the possibility that an additional field type could be added as a plugin to provide that validation. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          There is a discussion forum (http://moodle.org/mod/forum/discuss.php?d=111049#p527700) in which Sean Farrelll provided some code for implementing something related to checking for dates. I have not looked carefully at the code to see what it actually does but wanted to at least make a reference to it here. Peace - Anthony

          Show
          Anthony Borrow added a comment - There is a discussion forum ( http://moodle.org/mod/forum/discuss.php?d=111049#p527700 ) in which Sean Farrelll provided some code for implementing something related to checking for dates. I have not looked carefully at the code to see what it actually does but wanted to at least make a reference to it here. Peace - Anthony
          Hide
          Anthony Borrow added a comment -

          Martin - Would it be a good idea to add a field to hold the value of a regular expression in the user_info_field table to allow data validation or should we just use param4 or param5? I figured if we were going to add a field for 2.0 then now is the time. Peace - Anthony

          Show
          Anthony Borrow added a comment - Martin - Would it be a good idea to add a field to hold the value of a regular expression in the user_info_field table to allow data validation or should we just use param4 or param5? I figured if we were going to add a field for 2.0 then now is the time. Peace - Anthony

            People

            • Votes:
              5 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: