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.

General Questions

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

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

CurrencyField problem


Reply

6 Posts   1249 Views

Avatar
jamesg

3 September 2010 at 12:33pm (Last edited: 3 September 2010 12:34pm), Community Member, 8 Posts

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

3 September 2010 at 12:47pm Community Member, 8 Posts

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

30 September 2010 at 1:43pm Community Member, 25 Posts

got the same problem. could u solve it ?

cheers
matze

Avatar
vancouverWill

24 March 2011 at 9:26am Community Member, 121 Posts

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

11 August 2011 at 2:36pm (Last edited: 15 January 2013 5:35pm), Community Member, 133 Posts

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

11 August 2011 at 2:53pm Community Member, 133 Posts

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