Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,757 members, 7,824,172 topics. Date: Saturday, 11 May 2024 at 02:33 AM

Texarea Truncating Text Issues - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Texarea Truncating Text Issues (717 Views)

Twitter Officially Increased The Text Limit But Some Think It's Not Cool �� / Transcriber Needed. Can You Convert Audio File To Text? Let's Talk / Tip To Write Or Comment In Blue Color Text On Facebook (2) (3) (4)

(1) (Reply) (Go Down)

Texarea Truncating Text Issues by cbrass(m): 4:34pm On Sep 04, 2015
Please what do you think is wrong here, when I copy a long post from somewhere and paste it into my textarea then submit, it will cut the post into half sometime not even up to half of the post I submitted will be inserted into the db. Have checked and rechecked my codes but don't seem to know what is wrong I aslo noticed it doesn't behave like that on a particular laptop I use, but when i tried other browsers and laptops but it's still behaving like that

Adewasco2k slyrox onyengbu
Re: Texarea Truncating Text Issues by onyengbu: 5:18pm On Sep 04, 2015
cbrass:
Please what do you think is wrong here, when I copy a long post from somewhere and paste it into my textarea then submit, it will cut the post into half sometime not even up to half of the post I submitted will be inserted into the db. Have checked and rechecked my codes but don't seem to know what is wrong I aslo noticed it doesn't behave like that on a particular laptop I use, but when i tried other browsers and laptops but it's still behaving like that

Adewasco2k slyrox onyengbu
let me guess, the form submission is being done via ajax/ajax jquery call?
Re: Texarea Truncating Text Issues by cbrass(m): 6:13pm On Sep 04, 2015
onyengbu:

let me guess, the form submission is being done via ajax/ajax jquery call?

Yes bro
Re: Texarea Truncating Text Issues by spikesC(m): 6:28pm On Sep 04, 2015
Log text before database insert

I am guessing your column is varchar and of course has a limit
Re: Texarea Truncating Text Issues by cbrass(m): 6:46pm On Sep 04, 2015
spikesC:
Log text before database insert

I am guessing your column is varchar and of course has a limit

No it's TEXT
Re: Texarea Truncating Text Issues by onyengbu: 7:07am On Sep 05, 2015
cbrass:


Yes bro
I have been into that problem before. It is not database table settings. It is being caused by improper escaping . It is quite a strange occurence then but if you check the text being truncated you will discover that the point of trunctiom has a single quote or apostrophe or some hidden characters.
The solution is to use javascript escaping methods (google itcos I cant do that now) and escape the js variable on the jquery side of your script before it gets to php. PHP escaping methods wont help because the text gets truncated before it gets to the server..
If JS escaping method didnt help, use a form submissbon library like form.malsup.com. Even if your textarea is in a loop, you are still fine because you bind each form submit to a class which you create from the ids of your loop.

Best regards
Re: Texarea Truncating Text Issues by cbrass(m): 12:38am On Sep 06, 2015
onyengbu:

I have been into that problem before. It is not database table settings. It is being caused by improper escaping . It is quite a strange occurence then but if you check the text being truncated you will discover that the point of trunctiom has a single quote or apostrophe or some hidden characters.
The solution is to use javascript escaping methods (google itcos I cant do that now) and escape the js variable on the jquery side of your script before it gets to php. PHP escaping methods wont help because the text gets truncated before it gets to the server..
If JS escaping method didnt help, use a form submissbon library like form.malsup.com. Even if your textarea is in a loop, you are still fine because you bind each form submit to a class which you create from the ids of your loop.

Best regards


Thanks bro I used encodeURIComponent() to escape the characters before the ajax call and it's working perfectly now

Once again thank you
Re: Texarea Truncating Text Issues by onyengbu: 11:58am On Sep 06, 2015
cbrass:



Thanks bro I used encodeURIComponent() to escape the characters before the ajax call and it's working perfectly now

Once again thank you
Thats exactly what I used back when I had that problem but its been a long time and I can hardly locate which project I used it on.

You are welcome.

(1) (Reply)

How To Delete A Story About Yourself From Google Search / Wordpress Experts, Get In Here Please Please Please Please. / Download 1960help.com Android App

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.