• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1564
  • Last Modified:

Javascript Remove comma from form input

I have a form element, <INPUT id=aircraftcost name=aircraftcost>

Is it possible to write a javascript that upon submit removes any comma from the field?

Can someone show me what I need to insert into the page to do this?
0
pda4me
Asked:
pda4me
  • 3
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
<form onSubmit="var val = this.aircraftcost.value; if (val) this.aircraftcost.value=val.replace(/,/g,'')">

please note the  '') are two single quotes
0
 
pda4meAuthor Commented:
Awesome, thanks for the help!
0
 
torrid333Commented:
Does this work in IE7???
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Michel PlungjanIT ExpertCommented:
Why should it not work?
0
 
torrid333Commented:
Because some of the older IE browsers don't support all of javascript.  But it might be IE6 not IE7 that it is an issue.  Anyway I found a solution, tested it in IE7 using spoon, and everything is good now.  Thanks.
0
 
Michel PlungjanIT ExpertCommented:
RegExp as argument to replace is supported by IE6 too

http://msdn.microsoft.com/en-us/library/ie/t0kbytzc(v=vs.94).aspx
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now