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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Userforms date validation not working

Go to End

9 Posts   4547 Views


Community Member, 2 Posts

7 September 2010 at 2:30am

Edited: 07/09/2010 2:35am


I've been having a slight problem validating date picker fields with userforms.

If I create a date field and default it to today’s day it will be displayed in the format "6 Sep 2010" When this is submitted it validates.

If I then use the date picker to choose a different date it will be displayed in the format "09/07/2010" the page will be submitted and pass the javascript validation but you'll be redirected back to the form with an error message displayed: "Please enter a valid date format (d MMM yyyy)"

I've had a look through the source code and can’t find where this validation is done or where the default date output is created, Could anyone point me in the right direction.

On another note, I also can’t find the code that creates the javascript output; I’d like to change some of the validation rules there too.

I've put a test form up so any of you can take a look at

I've also posted my template's which isn’t particularly complicated file at

Thanks in advance


Community Member, 2 Posts

7 September 2010 at 3:17am

I've found the solution to the first problem.

Changing line 51 of userforms/code/editor/EditableDateField.php from

$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker();


$('input[name^=EditableDateField]').attr('autocomplete', 'off').datepicker({dateFormat: 'd M yy'});

Makes the date picker output the date in the same format as the current date.

Now just to find out where the rest of the javascript comes from.


Community Member, 219 Posts

22 June 2011 at 3:42am

isn't this just managed by the locale you set in config?
it worked for me anyway... i added this:
// Set the site locale


Community Member, 267 Posts

1 November 2011 at 1:48am

I have a simulair problem, when you click on the datePicker, you get the date, but the validation says it's not correct/filled in.

I've downloaded the latest version from gitHub today.. but the validation is going wrong.

It displays the date as 31 Oct 2011 for instance.

i've set the site to dutch in the config
setlocale(LC_ALL, 'nl_NL');

Any idea how to fix this?


Community Member, 219 Posts

2 November 2011 at 6:57am

Edited: 02/11/2011 6:57am

first thing to check, the time/date settings for your user account under the security tab!


Community Member, 21 Posts

24 October 2012 at 3:17pm

Edited: 24/10/2012 4:17pm

I'm having the same issue borriej.
I've check my date/time setting - all on Default. No difference, I still get a validation error that the field is empty when it clearly is not..

Anyone else have any ideas?

It seems that it only breaks if you create a DateField, make it required. Save it. And then change it back to being not required.
I deleted the instance of DateField that was being problematic, and added it again, and all seems to be working as expected.

Should a bug like this be reported?


Community Member, 1 Post

27 November 2012 at 4:40am

We are experiencing the same issue with our sites. When we add 'required' to a date field suddenly the locale set to en_US when the system is setup for en_GB.


If we find a solution we'll post.


Community Member, 470 Posts

1 December 2012 at 5:52am

Report it and see what Will has to say since it seems others have it too?

Go to Top