Avatar of Melody Scott
Melody ScottFlag for United States of America

asked on 

Need to remove a character from a form upon submission.

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.
Web DevelopmentPerl* Webforms

Avatar of undefined
Last Comment
Melody Scott
Avatar of David Favor
David Favor
Flag of United States of America image

To remove a $ character from any string...

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

Open in new window

Avatar of Melody Scott
Melody Scott
Flag of United States of America image

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Melody Scott
Melody Scott
Flag of United States of America image

ASKER

That's pretty cool, thanks!
Avatar of Melody Scott
Melody Scott
Flag of United States of America image

ASKER

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">
Avatar of Melody Scott
Melody Scott
Flag of United States of America image

ASKER

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

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

78K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo