Advertisement:

Author Topic: Error message "Title too long" doesn't say max length  (Read 2099 times)

marylooo

  • Newbie
  • *
  • Posts: 16
Error message "Title too long" doesn't say max length
« on: October 07, 2013, 12:41:46 am »
I tried creating a listing with a title that was 120 characters long.

When I clicked "Add Listing", I got the following error message:
Title too long (en_US).

I am glad there was an error message, but I would like for it to also tell me what the maximum length is. All I know is it is less than 120 characters. I expect some users to be frustrated with that... having to just figure it out via trial and error. Some of them may give up and leave the site.

I see this behavior in both the back-end/admin "Add Listing" page, and in the front-end/user "Add Listing" page.

I would like for the error message to display the maximum number of characters allowed. I would also like for it to display the number of characters entered, in case the user wasn't counting them himself or herself as he/she entered the title. They might wonder, "Do I need to cut it down by half, or just trim a few letters from the end?"

I checked the .po file (language file), but don't see the error message in there. I was going to just hard-code the value into a translated string, but since the original string isn't in there, I don't think doing this with a .po file is an option.

Do any of you have more descriptive error messages implemented?

Update: So far, through trial-and-error, I see that 91 characters is below the limit (i.e. 91 characters is OK).
« Last Edit: October 07, 2013, 12:50:38 am by marylooo »

InstaladorX

  • Full Member
  • ***
  • Posts: 109
  • I live without rest! Osclass 3.2.1 Theme Bender
Re: Error message "Title too long" doesn't say max length
« Reply #1 on: October 24, 2013, 07:36:32 pm »
You can change these values ​​in your file 'os-includes/osclass/ItemActions.php'.

Looking for lines 98-108. and lines 309-318.


Code: [Select]
foreach(@$aItem['title'] as $key => $value) {

                if( osc_validate_text($value, 1) && osc_validate_max($value, 100) ) {
                    $title_message = '';
                    break;
                }

                $title_message .=
                    (!osc_validate_text($value, 1) ? sprintf(_m("Title too short (%s)."), $key) . PHP_EOL : '' ) .
                    (!osc_validate_max($value, 100) ? sprintf(_m("Title too long (%s)."), $key) . PHP_EOL : '' );
            }

I changed the maximum size of the title of my ad to 45, which in my case was well settled.

In this case, only changed values ​​between lines 309-318. And my code was as shown below.

Code: [Select]
foreach(@$aItem['title'] as $key => $value) {
                if( osc_validate_text($value, 1) && osc_validate_max($value, 45) ) {
                    $td_message = '';
                    break;
                }

                $td_message .=
                    (!osc_validate_text($value, 1) ? _m("Title too short.") . PHP_EOL : '' ) .
                    (!osc_validate_max($value, 45) ? _m("Title too long.") . PHP_EOL : '' );
            }
« Last Edit: October 24, 2013, 08:01:53 pm by InstaladorX »