Limit field input length to database datatype field size

QuestionsLimit field input length to database datatype field size
Richard Samson asked 7 years ago

Hi,
Is there a simple way to prevent users typing to many characters into a field/column?
For example, my SQL database field datatype is set to VARCHAR(20), if the user enters 21 characters an SQL error will be generated, in this scenario I’d want to set the maximum field length to 20 characters.  Is there a way of limiting the maximum number of characters the user can enter?
Thanks.

2 Answers
Abu Ghufran Staff answered 7 years ago

With that column, You can use html input validation.
$col[“editoption”][“maxlength”] = 20;

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Richard Samson replied 7 years ago

Fantastic thanks, I’ve been trying custom validation and knew there had to be something simple. I can’t find this mentioned on your /docs page, it may be something worth adding? Thanks.

Anders answered 3 years ago

Note: should be $col[“editoptions”][“maxlength”] = 20;

editoptionS

/Anders

Your Answer

4 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?