I need an integer form field with has a validation of min 11 digits and max 11 digits. In other words; the user has to fill in an 11 digit code.

How do i make this field and validation?


I managed the field by setting a min of 10000000000 and max of 99999999999. But now i get this validation message:

RIZIV number: the value may be no greater than 99999999999.

How do i change this validation/error message to something like:

Fill in your right 11 digits RIZIV number.

  • do you need a custom validation? Jan 28 '16 at 3:43
  • @Adrian Cid Almaguer no. Just change the error message of field_riziv_number
    – meez
    Jan 30 '16 at 13:38

Go to admin/config/people/accounts/fields add an integer field and set the limitations and by hook_user_update you can check the validation after saving the user profile.

  • but how do you set the limitations exactly? Its not possible i think?
    – meez
    Jan 27 '16 at 20:54
  • 1
    when the number of digits must be 11, so the min is 10000000000 and the max is 99999999999. right? Using this configuration no more validation is needed. Unless the zero at the beginning is allowed. In this case you need to add a text field and using hook_user_update check for validation
    – M a m a D
    Jan 27 '16 at 21:41
  • i update my question. Please adjust your answer, so i can accept it. Thanks.
    – meez
    Jan 28 '16 at 6:57
  • @MeesFrenkelFrank using string overrides module in drupal.org/project/stringoverrides you can change all the messages of your site.
    – M a m a D
    Jan 28 '16 at 9:32
  • i tried this module but unfortunately its not working..?
    – meez
    Jan 28 '16 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.