Answers.Body: <p>being able to set a length make sense. As you describe, you might want to have the length limited, because it's a zip code, a country code, a whatever you know has a fixed length.</p>
  
  <p>The problem is not on the database definition, but on the user interface, that should prevent being able to put more chars that the field can accept.</p>
  
  <p>Where do you experience the problem? is this in the back-office or using profiles?</p>
  
  <p>Would be awesome if you could correct civicrm core to the check is done at the interface level (don't make the field longer than what the database can store) instead of the ugly error triggered by the database.</p>
  
  <p>(You might want to check on the next version of civi see if you're lucky and that has already been fixed)</p>
  
  <p>X+</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-10T13:52:05.517Z
Answers.Text: The problem happens in both the back-office and profiles.  I agree that it is a UI error, I'm just surprised it's there! :)
Answers.UserDisplayName: Cheryl
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-07T08:45:37.190Z
Answers.Text: It throws a civi/mysql exception in civicrm 4.6.20 if data in custom text field exceeds pre-defined value, so, guess, it hasn't been fixed as of Aug 2016
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-09T21:03:55.543Z
Answers.LastActivityDate: 2015-12-09T21:03:55.543Z
Answers.UserDisplayName: Xavier
Body: <p>I know the documentation says you should leave it the same, but suppose I know I want the text field to be only 3 characters every time?</p>
  
  <p>I can set it fine in custom fields, but when I go to enter data, and a user mistakenly puts in more than 3 characters, it throws a database error. Is there somewhere else besides the custom field specification where I can set up CiviCRM to validate user input?</p>
  
  <p>(note: this can be reproduced on the civicrm demo server)</p>
  
Tags: <custom-fields><database><error>
Title: Why are you allowed to set DB field length on Text fields?
ThreadText: # Why are you allowed to set DB field length on Text fields?
  
  (Asked by: username_0 on 2015-12-09)
  
  I know the documentation says you should leave it the same, but suppose I know I want the text field to be only 3 characters every time?
  
  I can set it fine in custom fields, but when I go to enter data, and a user mistakenly puts in more than 3 characters, it throws a database error. Is there somewhere else besides the custom field specification where I can set up CiviCRM to validate user input?
  
  (note: this can be reproduced on the civicrm demo server)
  
  **Tags:** custom-fields, database, error
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-12-09. Score: 4 | Accepted answer
  
  being able to set a length make sense. As you describe, you might want to have the length limited, because it's a zip code, a country code, a whatever you know has a fixed length.
  
  The problem is not on the database definition, but on the user interface, that should prevent being able to put more chars that the field can accept.
  
  Where do you experience the problem? is this in the back-office or using profiles?
  
  Would be awesome if you could correct civicrm core to the check is done at the interface level (don't make the field longer than what the database can store) instead of the ugly error triggered by the database.
  
  (You might want to check on the next version of civi see if you're lucky and that has already been fixed)
  
  X+
  
  > **Comments:**
  > **username_0**: The problem happens in both the back-office and profiles.  I agree that it is a UI error, I'm just surprised it's there! :)  
  > **username_2**: It throws a civi/mysql exception in civicrm 4.6.20 if data in custom text field exceeds pre-defined value, so, guess, it hasn't been fixed as of Aug 2016  
  
  ---
  
  