MyBB Community Forums

Full Version: [F] Maximum Length in Custom Profile Fields do not work??????? [C-StefanT]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I set Maximum Length in Custom Profile Fields is 65, but anymember can type over 65 charaters easily.

[Image: attachment.php?aid=14435]
It works for text boxes, just not text areas... I'll move this to bug reports, I can reproduce so I'd say it's a bug.
(2009-06-24, 09:51 AM)MattRogowski Wrote: [ -> ]I can reproduce so I'd say it's a bug.

Maybe because the textarea tag doesn't have a maxlength attribute? Toungue

You can't set a maxlength on a textarea, just for textboxes. It's a HTML thing, not MyBB.
But it says it applies to text areas, if the bug isn't that there isn't a length limit, the bug is that it says the length limit applies, it's misleading.
Maybe the Maximum length field should be hidden when selecting Text area in the dropdown then?
It's misleading.
A-ha! Here's to eating and posting again...

I see what you mean. I agree that it's misleading - should it be hidden or should the text just be altered?
I think it should be hidden.
The limit for text boxes is done when you POST the input to the MyBB scripts which then checks the length and returns an error if it's over. There is no way in HTML to add a limit to a text area field.
I set
[Image: attachment.php?aid=14455]
[Image: attachment.php?aid=14456]
and result. there are 90 charaters /////
After looking into this, I can't find anywhere in the user datahandler that checks the length of the textarea. I haven't looked elsewhere though, as I think the check should be in verify_profile_fields.

In ./inc/datahandlers/user.php, around line 481, find this:

else
{
	$options = $db->escape_string($profile_fields[$field]);
}

Add above:

elseif($type == "textarea")
{
	if(my_strlen(trim($profile_fields[$field])) > $profilefield['maxlength'])
	{
		$this->set_error('max_limit_reached', array($profilefield['name'], $profilefield['maxlength']));
	}

	$options = $db->escape_string($profile_fields[$field]);
}

'max_limit_reached' is a variable that should be added into datahandler_user.lang.php.:

$l['userdata_max_limit_reached'] = 'You entered an invalid number of characters for the "{1}" field. Please fill in this field with no more than {2} characters.';

Fixes it for me. Smile
Pages: 1 2