Skip to main content
Inspiring
February 17, 2011
Question

How to get rid of special char? Help please!

  • February 17, 2011
  • 3 replies
  • 845 views

I'm having a hard time creating a form field that only accepting number.

The ideal way would be using ajax or javascript but I don't know how so I tried to use form submit instead.

There are 2 text fields & one drop down where user can enter dollar amount, then select a fee from a drop down.

The 3rd textbox will then display the total amount from 1st field +  2nd field, real simple.

1. Enter amount, for example, user enter $10 on the 1st. field then

2 Select fee range : $1 to $200     : $20 <<<< for example user select this value

                             $201 to $500  : $30

                             etc

then,

3. Total : $10 + $20 = $30 <<< shown on 3rd text field

I need to filter 1st text field to only get the number. If user enter $10, I should get rid of the $ sign or if user enter any characters other then numbers (including

decimal) my program should be able to only extract the number (and decimal)

When user select the drop down, I submit the form to self, calculate this 2 numbers and show the result in the 3rd text field.

I tried to use ReplaceNoCase but it generates error since it doesn't like the empty value on the 2nd string attribute:

#ReplaceNoCase(Form.FirstTextBox, $, ,ALL)# >>>> this generates error because it is trying t replace it with a blank space..please help!

This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
February 19, 2011

replaceNoCase(Form.FirstTextBox, "$", "" , "all")

Owainnorth
Inspiring
February 18, 2011
I tried to use ReplaceNoCase but it generates error since it doesn't like the empty value on the 2nd string attribute:

#ReplaceNoCase(Form.FirstTextBox, $, ,ALL)#

this generates error because it is trying t replace it with a blank space

For what it's worth, that's not why it's erroring. Read the error message and documentation and you'll realise you were on the right track, but didn't use quotes in the right place.

Inspiring
February 18, 2011

Use cfinput validate="integer" and don't let people enter dollar signs.

I recommend the book, Teach Yourself Javascript in 24 Hours.  It's how I learned javascript.