Make DateTime field required by user


(Ryan Archer) #1

How do I make a dateTime field be required? Currently users can submit form without putting a date in there. I can see that I can use JS to assist in validation (to correct bad dates) but there is no way to force users to enter dates using the drop down pickers.

 

Would love to use text input and use type of dateTime but not many browsers support that HTML5 standard right now.

 

Currently using Squiz Matrix 4.18.4. We plan to upgrade to latest Squiz very soon.


(Peter McLeod) #2

Hi

 

In the options section for the date time form question type there is a row of Check box options to 'Allow blank?' for each of the date components.

 

Leaving all blank should result in a submission error.

 

http://manuals.matrix.squizsuite.net/custom-form/chapters/datetime-question-type

 

Thanks

Peter


(Tim Davison) #3

Do you mean datetime for a form or a metadata field?

 

My understanding is for metadata fields you can't.


(Ryan Archer) #4

Date time for a form was what I was looking for.

The 'Allow Blank' solution Peter provided worked for me. Just didn't seem that obvious at first.


(Ryan Archer) #5

Sorry I have to get back onto this thread but I see no validation method that will prevent the user from inserting an incorrect date. Say for instance I don't want to accept any dates prior to 1st November, 2015 - it just doesn't throw up an error message even though I set minimum date to this parameter.


(Anthony Ponomarenko) #6

The minimum and maximum date parameters will only restrict the values seen on the front end. 

 

eg. if you set min year to 1988 and max year to 2010 the select field year will only show values from 1988 to 2010

 

If the years are the same this will restrict the month values etc.

 

There is currently no way within your matrix version to validate the entered date to a specific range that you require. 

 

You will need to look into a js solution.