By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

handling commas

P: n/a
Hello,

I am posting a html form to a php processing page, which produces a csv file
from the form data. However if the user inputs a comma then it screws up my
data.

So i'd like to know how to strip my data of commas before submitting to the
php processor.

Or maybe not strip the commas but handle them better.

many thanks

darren

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
darren wrote on 08 mrt 2005 in comp.lang.javascript:
I am posting a html form to a php processing page, which produces a
csv file from the form data. However if the user inputs a comma then
it screws up my data.

So i'd like to know how to strip my data of commas before submitting
to the php processor.

Or maybe not strip the commas but handle them better.


<form
onsubmit='this.a.value=this.a.value.replace(/,/g,"")'>
<input name=a>
</form>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

P: n/a
Lee
darren said:

Hello,

I am posting a html form to a php processing page, which produces a csv file
from the form data. However if the user inputs a comma then it screws up my
data.

So i'd like to know how to strip my data of commas before submitting to the
php processor.

Or maybe not strip the commas but handle them better.


Any sort of critical data handling MUST be done on the server
in your PHP code. You don't know that the user has Javascript
enabled, and a malicious user could easily bypass your processing.

Jul 23 '05 #3

P: n/a
darren wrote:
I am posting a html form to a php processing page, which produces a
csv file from the form data. However if the user inputs a comma then
it screws up my data.


Instead, create a CSV file using the correct format. Quote your values, and
commas in the values won't matter. Then escape quotes within the values to
be "" in the PHP side. Then you're bullet-proof.

--
Matt Kruse
http://www.JavascriptToolbox.com
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.