Advertisement:

Author Topic: [help soon to be tip] The perfect title and description  (Read 1556 times)

keerthi

  • Hero Member
  • *****
  • Posts: 505
[help soon to be tip] The perfect title and description
« on: June 26, 2014, 11:09:17 pm »
I am pretty sure that many of the osclass admins have experienced this. Whenever your users post an ad they do so with ALL CAPS or unwanted special symbols such as ">>>> <<<<  ******" to get attraction. But I hope javascript could save us from this without any modifications in core files. I require your help to create the perfect title and description. Which will be useful for all the users. I have posted a query in stack oveflow here which may also be useful.

http://stackoverflow.com/questions/24437600/remove-unwanted-symbols-and-caps-from-a-field/24437881#24437881

The perfect title or description should have.

1. No all caps.
2. no special symbols.
3. First letter at the beginning of a sentence to be in caps.

If there is an alternate way to do it please note. Also make sure the code is "NOT to validate the user's input" but just to convert.

Here is a helpful code (credits to jcaron) looked most suitable for us.

Code: [Select]
var text = $('#title').val().toLowerCase().replace(/[^\w\s]/g,"").replace(/(^\s+|\s+$)/g,"").replace(/\s+/g," ");
$('#title').val(text.charAt(0).toUpperCase() + text.substr(1);

Also css could help.

Code: [Select]
.link { text-transform: lowercase; }
.link:first-letter { text-transform: uppercase; }

After all your suggestions. I will make sure to test it and put down the right code for you (with credits to the user ofcourse)

itcafeonline

  • Full Member
  • ***
  • Posts: 245
Re: [help soon to be tip] The perfect title and description
« Reply #1 on: September 25, 2014, 02:39:33 am »
Were you able to zero-in on this? All Caps in Subject and description kinda messes up everything. Pointers please? Thanks

keerthi

  • Hero Member
  • *****
  • Posts: 505
Re: [help soon to be tip] The perfect title and description
« Reply #2 on: September 25, 2014, 08:16:51 am »
yeah. Thats why I have marked it as "help soon to be tip". I am not sure how and where to implement this in osclass.