Suggestions on constraining input field length

This is a two-part question.

  1. What is the best way to implement a maxlength on a text input field? Check On Change for the length comes to mind but it would be nice if there was a simple way that doesn’t require coding for an HTML attribute.

  2. Is it best practice to validate all input lengths before inserting them into the database as a double check to make sure they’re not longer than the max length of the column?

Thanks,
Tim

Hi @Tim_Jones

  1. You can create a Cloud Code handler, such as “before create,” and add a simple check for the input length before saving data to the database. This approach allows you to enforce the character limit without modifying HTML attributes directly.

  2. Yes, it’s considered a best practice to validate input lengths before inserting them into the database. Adding a length validator serves as an essential double-check to ensure data integrity.

Regards,
Viktor

Thanks @Viktor_Mudrevsky

For 1) that seems like a lot of work relative to setting maxlength=“20”. I’m surprised it is not a setting of the input -

Hello @Tim_Jones!

Thank you for the suggestion!
I’ve created a ticket for the implementation of this feature.
We’ll keep you updated on this topic once it’s ready.

Regards,
Alexander

Thank you!

Hi @Tim_Jones,

We’ve just updated cloud servers with a feature you described above. Added Max Length for the Input component.

Regards,
Bohdan

1 Like

Thanks @Bohdan_Vynarchuk! That is a great improvement to the UI builder.

Best,
Tim