473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Prevent quotes in form text area

Hello,

I have a simple form text area for people to add comments in. The problem is
that using the standard
<TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA>

Allows people to put in quotes like: Please ensure "bob" is listed as the
first name not "bobby".

When that happens, the next processing of the text area input is submitted
as another variable. In the example above the first set of quotes in front
of bob then end the variable.

What I need is a way to either strip the quotes or prevent them from being
input in the first place.

Any ideas?

Thank you,

Michael
--
http://www.cuesplus.com
http://www.cuesplusbilliards.com
http://www.stixplus.com
(remove SPAMBLOCK if replying by e-mail)
Jul 20 '05 #1
7 6380
Cues Plus wrote:
Hello,

I have a simple form text area for people to add comments in. The problem is
that using the standard
<TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA>

Allows people to put in quotes like: Please ensure "bob" is listed as the
first name not "bobby".

When that happens, the next processing of the text area input is submitted
as another variable. In the example above the first set of quotes in front
of bob then end the variable.

What I need is a way to either strip the quotes or prevent them from being
input in the first place.

Any ideas?

Thank you,

Michael


The value of the textarea could possibly contain new line characters as well,
which can lead to things like:

var s = "This is line 1 of the textarea and
this is line two of the text area";

So store the textarea in it's entirety, then when putting it back into a
variable, escape double-quotation marks and turn new lines and returns into \n
and \r:

s = <outputOfTheTextarea>.replace(/\x22/g, '\\"').replace(/\n/,
'\\n').replace(/\r/, '\\r');

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2
Lee
Cues Plus said:

Hello,

I have a simple form text area for people to add comments in. The problem is
that using the standard
<TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA>

Allows people to put in quotes like: Please ensure "bob" is listed as the
first name not "bobby".

When that happens, the next processing of the text area input is submitted
as another variable. In the example above the first set of quotes in front
of bob then end the variable.

What I need is a way to either strip the quotes or prevent them from being
input in the first place.


You must never rely on client-side code to ensure that form
input is valid. You don't know that your customer even has
JavaScript enabled.

What you really need to do is to fix your CGI script so that
it handles the input correctly.

Jul 20 '05 #3
@SM
Cues Plus a ecrit :

Hello,

I have a simple form text area for people to add comments in. The problem is
that using the standard
<TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA>

Allows people to put in quotes like: Please ensure "bob" is listed as the
first name not "bobby".

What I need is a way to either strip the quotes or prevent them from being
input in the first place.


Try :

<textarea onchange="this.value=this.value.replace('"','|');"
or
<textarea onchange="this.value=this.value.replace('\"','\|') ;"
Jul 20 '05 #4
I understand that completely... The problem is not really with the CGI
script because it is designed to spit out exactly what was put in. The
problem lies with the form the CGI script feeds. (I could fix the CGI if I
had access to it though).

The problem is mostly cosmetic without JavaScript enabled anyway... With out
it (and if someone used quotes) the output on the screen would look like:

">

But if I could get the quotes stripped out it would just show a blank line
like it is supposed to.

Thanks for the input but so far I'm not able to use any suggestions
successfully.

Michael
--
http://www.cuesplus.com
http://www.cuesplusbilliards.com
http://www.stixplus.com
(remove SPAMBLOCK if replying by e-mail)
"Lee" <RE**************@cox.net> wrote in message
news:br*********@drn.newsguy.com...

You must never rely on client-side code to ensure that form
input is valid. You don't know that your customer even has
JavaScript enabled.

What you really need to do is to fix your CGI script so that
it handles the input correctly.

Jul 20 '05 #5
"Cues Plus" <sa***@SPAMBLOCKcuesplus.com> writes:
I understand that completely... The problem is not really with the CGI
script because it is designed to spit out exactly what was put in.


That *is* a problem. Simply spitting out what comes in, will not
generate valid HTML. The output of the CGI-script is used as HTML,
so it should be HTML.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6
Lee
Cues Plus said:

I understand that completely... The problem is not really with the CGI
script because it is designed to spit out exactly what was put in.


That's exactly the problem with the script.
It should have more intelligence.

Jul 20 '05 #7
Irrelevant to the discussion though. Which is: how to prevent people from
putting in quotes in a textarea of a form or to convert the quotes to
something else.

Michael

--

(remove SPAMBLOCK if replying by e-mail)
"Lee" <RE**************@cox.net> wrote in message
news:bs********@drn.newsguy.com...
Cues Plus said:

I understand that completely... The problem is not really with the CGI
script because it is designed to spit out exactly what was put in.


That's exactly the problem with the script.
It should have more intelligence.

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mudassar | last post by:
Hello I've been trying to figure this problem out for quite a while and I'm having no joy. I'll give you some background info, I'm creating a form and one of the fields in the form is a big ...
1
by: mudassar | last post by:
Hello I've been trying to figure this problem out for quite a while and I'm having no joy. I'll give you some background info, I'm creating a form and one of the fields in the form is a big ...
2
by: crjunk | last post by:
I have the following code in my web page. Dim tmpReplace As String 'Giving tmpReplace the value from the textbox on the webform. tmpReplace = txtComments.Text.Trim 'Prevents report from...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
1
by: Kirthikaiitm | last post by:
Hi, I have a image button (APPLY) On clicking apply button how to move the content from textbox to another textarea. I wrote the code in JScript. But once i click APPLY button the form is...
3
by: blackrunner | last post by:
ERROR in my Query?! ERROR: Element GESCHLECHT is undefined in FORM. i think everything ok. Maby somebody can help me here Element GESCHLECHT is undefined in FORM. The error occurred...
14
by: jmDesktop | last post by:
I have a food menu. Each area, like beverages, grill, etc. have items under them, Coke, Tea, Coffee would be under beverages for example. I want to add a new drink to beverages. In my database...
4
by: AAaron123 | last post by:
<body runat="server" id="MainBody"> <form id="form1" runat="server" style="background-color:green; width: 100%; height: 100%"> <br /> Table1" runat="server" Style="background-color:Yellow;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.