Need to remove a character from a form upon submission.

Melody Scott
Melody Scott used Ask the Experts™
on
Hi, we have a gift certificate form. magickitchen.com/gift/gift-certificates.html  - cart is written in PERL,

In the amount window, if someone enters a dollar sign before the number, they get an error. Error: Invalid input for VALUE: $|$35|

Is there a simple way to remove the $ sign if someone enters it, as the form is submitted? Or is there another simple solution?

As an interim measure, I'll be changing the placeholder text. Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
To remove a $ character from any string...

$str =~ s/\$//go;

Open in new window

Author

Commented:
Thanks... I'll need a little more explanation, I think. I know that's jquery, but I'm not sure how or where to add it to make that work. Thanks, David.
Top Expert 2016
Commented:
let your control only accept numbers
https://jsfiddle.net/Behseini/ue8gj52t/
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Author

Commented:
That's pretty cool, thanks!

Author

Commented:
Not sure why it isn't working here though: http://dev.magickitchen.com/gift/gift-certificates.html  scroll down to the form.

I have this in the head tag:
     <script language="javascript" type="text/javascript" src="/js/cart/jquery-1.7.1.min.js"></script>
 <script>
 $(".allownumericwithdecimal").on("keypress keyup blur",function (event) {
            //this.value = this.value.replace(/[^0-9\.]/g,'');
     $(this).val($(this).val().replace(/[^0-9\.]/g,''));
            if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
                event.preventDefault();
            }
        });
	</script>

Open in new window


And the input field has: <input class="form-control allownumericwithdecimal" name="gift_value" id="gift_value" type="text" placeholder="Amount (10 - 2500)*- enter without dollar sign">

Author

Commented:
Thanks gentlemen, the cart developer made changes to fix it, but this would have worked as well. Appreciated!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial