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.

All other Modules /

Discuss all other Modules here.

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

Userforms date validation not working


Go to End
Reply


9 Posts   2557 Views

Avatar
ColinMcCrory

Community Member, 2 Posts

7 September 2010 at 2:30am

Edited: 07/09/2010 2:35am

Hi!

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 http://formbuilder.kolin.me.uk/test/test-form/

I've also posted my template's Page.ss which isn’t particularly complicated file at http://pastie.org/1141548

Thanks in advance
Colin

Avatar
ColinMcCrory

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();   

to

$('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.

Avatar
CHD

Community Member, 218 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
i18n::set_locale('en_GB');

Avatar
borriej

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
i18n::set_locale('nl_NL');
setlocale(LC_ALL, 'nl_NL');

Any idea how to fix this?

Avatar
CHD

Community Member, 218 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!

Avatar
RuthAdele

Community Member, 19 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?

**UPDATE
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?

Avatar
DomS

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.

Weird!

If we find a solution we'll post.

Avatar
Liam

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