1

How can I force date validation upon input of a content type so that a user cannot type in 0000 as the year which causes an error in Drupal 7.

3
  • need more info. what type of form is this? also, my two cents: don't bother. if your user wants to be an idiot and type "0000" in the year field, they'll understand when they see an error and it doesn't work.
    – user5482
    Commented Jun 9, 2015 at 14:20
  • just on the normal content edit page.
    – Diana
    Commented Jun 9, 2015 at 14:21
  • yes I know but the tester insists on making this a high defect if he puts in 0000
    – Diana
    Commented Jun 9, 2015 at 14:22

2 Answers 2

3

You can use Field Validation to check against the date, it has a sub module or feature that has date validation.

You could also do this with a hook, probably hook node validate would be your best option for this.

0
0

You can use this module to define fields as date fields:

https://www.drupal.org/node/1455576

Alternatively, you could add JS or PHP validation of expected formats to your form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.