Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

CurrencyField problem


Go to End


6 Posts   1869 Views

Avatar
jamesg

Community Member, 8 Posts

3 September 2010 at 12:33pm

Edited: 03/09/2010 12:34pm

Hi,

I'm using Silverstripe 2.4.0 for a project at the moment and I am using a couple of CurrencyFields on a particular page type in the CMS.

Unfortunately I am unable to save the page as I keep getting the following javascript error:

$("Form_EditForm").validateCurrency is not a function

Has anyone else encountered this? and does anyone know of a fix?

Avatar
jamesg

Community Member, 8 Posts

3 September 2010 at 12:47pm

Additional info:

Currently have recreated this in Firefox 3.6.8 and the most recent version of Chrome on Mac OS X.

It only seems to be a problem when the CMS loads straight to that page (eg. if I click that page in the CMS and then refresh I will get the javascript error). However, if I load the CMS on a different page and then click on the page in question, I get no errors and it saves fine.

Avatar
Matze0681

Community Member, 25 Posts

30 September 2010 at 1:43pm

got the same problem. could u solve it ?

cheers
matze

Avatar
vancouverWill

Community Member, 121 Posts

24 March 2011 at 9:26am

I have this same issue, seems to be more of a bug than just a problem. Did any of you get this resolved?

cheers

Avatar
3dgoo

Community Member, 135 Posts

11 August 2011 at 2:36pm

Edited: 15/01/2013 5:35pm

To add to this. I have the same problem.

The problem is in:
sapphire\forms\CurrencyField.php

function:
function jsValidation()

particuallarly the regex pattern match:
/^\s*(-?\\\$?|\\\$-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/

To recreate this problem create a CurrencyField in your page. Select that page in the CMS. Refresh the page in your browser. In the firebug console you will notice the error:
invalid quantifier

Then when saving the page the following error occurs:
$("Form_EditForm").validateCurrency is not a function

When you change the regex it no longer throws errors (although it no longer correctly validates against what it should).

Avatar
3dgoo

Community Member, 135 Posts

11 August 2011 at 2:53pm

I found changing the regex to the following worked:
/^\s*[\$]?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/