oTree Forum >

Word count

#1 by Gabriela

Hi all, 

My current experiment requires users to enter a text. We're thinking about limiting the text to a set number of characters; however, I'm not sure if the models.LongStringField has this default option or should I set the limit in the html side? 

Thanks, 

Gabriela

#2 by mlt_123

models.LongStringField(label="Label", max_length=300)

should do if i recall correctly

#3 by Gabriela

Thank you! simple enough.

#4 by Chris_oTree

I recommend using FIELD_error_message, like this:

def xyz_error_message(player, value):
	if len(value) > 300:
		return "Input must not exceed 300 characters"

Write a reply

Set forum username