473,320 Members | 1,900 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,320 software developers and data experts.

Prevent unwanted comma

This may not be possible on the server side, so apologies if this is the
wrong group for this post.

My form consists of an unknown number of pairs of text boxes. They are
named textbox_a and textbox_b. I then split the comma separated list
that gets posted:

textbox_a = split(Request.Form("textbox_a"),",")
for i = ubound(textbox_a)
...insert into db

then do the same for textbox_b

If anyone puts a comma into one of the text boxes, this will result in
unmatched pairs. How can I deal with the comma, or prevent it?

Morris
Jul 22 '05 #1
5 1723
"Morris" wrote ...
This may not be possible on the server side, so apologies if this is the

wrong group for this post.

Hello Morris,

It would be possible server side, but I think by then for you it would be
too late...what you want to do is prevent the comma's being entered at all
(if I read your post correctly)..

Try this:

http://javascript.internet.com/forms...ss-script.html

It's blocking more characters than perhaps you need, I don't know - but it
might help, and would only need a little editing...

Another thing you could do would be to genereate unique id's for the boxes
instead...

I don't know what you're doing to create the form in the first place, but
you mentioned that its an "unknown number of text boxes" which to me
suggests that you have a loop of some sorts iterating through generating the
form, if this is the case, why not create a unique name on the fly, so
instead of just "textbox_a", you stick a number on the end, ie,
"textbox_a1", "textbox_a2"...etc, using the numbers from your iterating
loop.

The next part of course is working out how many were submitted so you can
get the values out using your request.form once the form is posted....couple
of ways...

1. after the iteration, write a hidden element with the total number of
iterations, pass this through and use it to parse the request.form the other
side...

ie,

<input type="hidden" name="iterations" value="<%=intIterations%>">

Then...once submitted..

intIterations = Request.Form("iterations")

For intLoop = 0 To intIterations

strFormElementName = "textbox_a" & intLoop

Request.Form(strFormElementName)

Next

Alternatively, you could get the ENTIRE request.form collection, and then do
the reverse, ie, whilst looping through the collection, ignore any other
fields that dont start with "textbox_a" or "textbox_b"...

Either would work, I've used both in practice in the past..

Hope this is of some use.

Regards

Rob
Jul 22 '05 #2
"Rob Meade" wrote in message
news:0%******************@text.news.blueyonder.co. uk...
: "Morris" wrote ...
:
: > This may not be possible on the server side, so apologies if this is the
: wrong group for this post.
:
: Hello Morris,
:
: It would be possible server side, but I think by then for you it would be
: too late...what you want to do is prevent the comma's being entered at all
: (if I read your post correctly)..
:
: Try this:
:
: http://javascript.internet.com/forms...ss-script.html
:
: It's blocking more characters than perhaps you need, I don't know - but it
: might help, and would only need a little editing...
:
: Another thing you could do would be to genereate unique id's for the boxes
: instead...
:
: I don't know what you're doing to create the form in the first place, but
: you mentioned that its an "unknown number of text boxes" which to me
: suggests that you have a loop of some sorts iterating through generating
the
: form, if this is the case, why not create a unique name on the fly, so
: instead of just "textbox_a", you stick a number on the end, ie,
: "textbox_a1", "textbox_a2"...etc, using the numbers from your iterating
: loop.
:
: The next part of course is working out how many were submitted so you can
: get the values out using your request.form once the form is
posted....couple
: of ways...
:
: 1. after the iteration, write a hidden element with the total number of
: iterations, pass this through and use it to parse the request.form the
other
: side...
:
: ie,
:
: <input type="hidden" name="iterations" value="<%=intIterations%>">
:
: Then...once submitted..
:
: intIterations = Request.Form("iterations")
:
: For intLoop = 0 To intIterations
:
: strFormElementName = "textbox_a" & intLoop
:
: Request.Form(strFormElementName)
:
: Next
:
: Alternatively, you could get the ENTIRE request.form collection, and then
do
: the reverse, ie, whilst looping through the collection, ignore any other
: fields that dont start with "textbox_a" or "textbox_b"...
:
: Either would work, I've used both in practice in the past..

Or, since your text fields are of unknown quantity, append an index to the
end of them so they each have a unique name. You can pass a hidden field
with the total number of fields and then use that as your max number of
items (-1) once posted. This eliminates the need to use client side code.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #3
Use array syntax to extract your data.

For i = 1 to request.form("textbox_a").count
texta = request.form("textbox_a")(i)
textb = request.form("textbox_b")(i)

'use the data for something

next
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Morris" <ke*****************@last.thanks> wrote in message
news:FK******************@fe2.news.blueyonder.co.u k...
This may not be possible on the server side, so apologies if this is the
wrong group for this post.

My form consists of an unknown number of pairs of text boxes. They are
named textbox_a and textbox_b. I then split the comma separated list
that gets posted:

textbox_a = split(Request.Form("textbox_a"),",")
for i = ubound(textbox_a)
...insert into db

then do the same for textbox_b

If anyone puts a comma into one of the text boxes, this will result in
unmatched pairs. How can I deal with the comma, or prevent it?

Morris

Jul 22 '05 #4
Roland Hall wrote:
"Rob Meade" wrote in message
news:0%******************@text.news.blueyonder.co. uk...
: "Morris" wrote ...
:
: > This may not be possible on the server side, so apologies if this is the
: wrong group for this post.
:
: Hello Morris,
:
: It would be possible server side, but I think by then for you it would be
: too late...what you want to do is prevent the comma's being entered at all
: (if I read your post correctly)..
:
: Try this:
:
: http://javascript.internet.com/forms...ss-script.html
:
: It's blocking more characters than perhaps you need, I don't know - but it
: might help, and would only need a little editing...
:
: Another thing you could do would be to genereate unique id's for the boxes
: instead...
:
: I don't know what you're doing to create the form in the first place, but
: you mentioned that its an "unknown number of text boxes" which to me
: suggests that you have a loop of some sorts iterating through generating
the
: form, if this is the case, why not create a unique name on the fly, so
: instead of just "textbox_a", you stick a number on the end, ie,
: "textbox_a1", "textbox_a2"...etc, using the numbers from your iterating
: loop.
:
: The next part of course is working out how many were submitted so you can
: get the values out using your request.form once the form is
posted....couple
: of ways...
:
: 1. after the iteration, write a hidden element with the total number of
: iterations, pass this through and use it to parse the request.form the
other
: side...
:
: ie,
:
: <input type="hidden" name="iterations" value="<%=intIterations%>">
:
: Then...once submitted..
:
: intIterations = Request.Form("iterations")
:
: For intLoop = 0 To intIterations
:
: strFormElementName = "textbox_a" & intLoop
:
: Request.Form(strFormElementName)
:
: Next
:
: Alternatively, you could get the ENTIRE request.form collection, and then
do
: the reverse, ie, whilst looping through the collection, ignore any other
: fields that dont start with "textbox_a" or "textbox_b"...
:
: Either would work, I've used both in practice in the past..

Or, since your text fields are of unknown quantity, append an index to the
end of them so they each have a unique name. You can pass a hidden field
with the total number of fields and then use that as your max number of
items (-1) once posted. This eliminates the need to use client side code.

Roland,

Belated thanks for your reply. I didn't use the javascript (although
I've added it to my snippets!) because your assumptions concerning how I
generate the form were spot on. I implemented your first server-side
suggestion - got rid of the arrays and reduced my code by 60%. Perfect.
Jul 22 '05 #5
"Morris" <no****@thanks.com> wrote in message
news:xJ*******************@fe1.news.blueyonder.co. uk...
: Roland Hall wrote:
: > Or, since your text fields are of unknown quantity, append an index to
the
: > end of them so they each have a unique name. You can pass a hidden
field
: > with the total number of fields and then use that as your max number of
: > items (-1) once posted. This eliminates the need to use client side
code.
: >
: Roland,
:
: Belated thanks for your reply. I didn't use the javascript (although
: I've added it to my snippets!) because your assumptions concerning how I
: generate the form were spot on. I implemented your first server-side
: suggestion - got rid of the arrays and reduced my code by 60%. Perfect.

You're welcome. Glad to hear you got something working.
Merry Christmas.

Roland
Jul 22 '05 #6

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

Similar topics

3
by: PW | last post by:
I'm testing the output of variables passed from my 1st ASP to my 2nd ASP. This is the code ... <% response.write "C-" & request.querystring("myCounter") response.write "<br>" response.write...
0
by: Mike Scott | last post by:
I've created several simple controls for use in a Compact Framework application and also use a full .Net framework app for testing. However, Visual Studio keeps creating RESX files for these...
4
by: David Beck | last post by:
I donwnload some files for processing every day that have unwanted characters in them. In VB6 I use the InputB to read in the text and the StrConv. vLinesFromFile =...
16
by: lovecreatesbeauty | last post by:
/* When should we worry about the unwanted chars in input stream? Can we predicate this kind of behavior and prevent it before debugging and testing? What's the guideline for dealing with it? ...
1
by: crka.crka | last post by:
Does anyone know a way to prevent a file being deleted so the only way to delete is via unistallation? Help would be very much appreciated.
4
by: vvenk | last post by:
Hello: I have a string, "Testing_!@#$%^&*()". It may have single and double quotations as well. I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma. I came across...
1
by: rkrishnaprasadh | last post by:
Hi, I am writing a small utility which runs on the server. As all the user require Administrative privilege for some or other reasons it becomes tedious preventing unwanted s/w installations. I want...
2
by: Jimbo | last post by:
Hi, I'd like to prevent Excel and Access (well any Microsoft Office application) from gaining access to a SQL 2000 instance, via an ODBC connection. If this we're SQL 2005, I create a...
21
by: array7 | last post by:
I have been reading a lot of archived threads about "page-break- inside: avoid" not supported by IE5, IE6 IE55, IE7 and Firefox (Mozilla), which creates a really unpleasant-looking printout with...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.