Active
Project:
Date
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2006 at 02:32 UTC
Updated:
8 Jan 2014 at 13:23 UTC
Jump to comment: Most recent
Use case:
I'm creating a birthday field for an application and the users must be under a certain age. I need to have validation for "required" but also further validation for "less than X" and/or "greater than X".
This is mostly a placeholder for the patch that I'm going to need to submit to do this and to get your input KarenS, if you have any, on whether you like this idea or if it needs to happen outside of the module.
Comments
Comment #1
karens commentedNot sure if it is best in or out. I think it depends on how generic the code can be. I'm certainly open to reviewing code to add this in.
Comment #2
karens commentedNo new features will be going into 4.7. Moving this to 5.x.
Comment #3
gregglesfwiw (to anyone else looking for this) I enforce this via hook_nodeapi in a custom module.
This seems nice to have, but it would clutter the interface and I'm not sure how hard/easy it would be to code.
Comment #4
moshe weitzman commentedCCK already has max/min value checking for certain field types. Seems like this should fit in without any new UI.
Comment #5
karens commentedMoving this to HEAD. No new features will be added to this version, but it could be considered for the 5.2 version now in HEAD.
Comment #6
sunhttp://drupal.org/node/99095 has been marked as duplicate of this.
Comment #7
Coyote commentedReally need this feature. Ideally, it would have to be something dynamic, not a static date, since it would have to not just check for a static minimum or maximum date, but would have to calculate based on the difference between the current date and the input date.
Comment #8
thepanz commented+1 for this feature, I'm going to implement it for my next project.. should I start with 1.x or 2.x version?
I'd like to know if version 2.x will be stable/compatible for production sites soon or I have to stay with 1.x version? :)
Regards, and compliments to KarenS for the great work!
Comment #9
karens commentedI'm hoping to release the 5.2 version very soon. There are just a few more things to clean up, but I'm out of town for the next two weeks with limited time to work on it, so it may not be until after that.
This feature won't be in the initial release, but we can re-visit it after a release. Patches welcome, of course (make patches against 5.2).
Comment #10
arlinsandbulte commentedThere is a module called validation API that might do this:
http://drupal.org/project/validation_api
I think artscoop successfully used it for this purpose. #579194: Date CCK : User can enter date not in range
I will mark as needs review... hoping that someone can verify that Validation API indeed works well for this purpose...
Comment #11
arlinsandbulte commenteddhalgren has another method to do this using rules:
ON event "Content is going to be saved"
IF Unchanged content is xxxx
AND Numeric comparison is true
([node:field_datelink-yyyy]<2004)
DO Show a configurable message on the site
(date must be greater than 31/12/03)
and
Page redirect to node/ass/xxxx
(Immediately issue the page redirect)
Marked that issue a duplicate of this one.
#563276: date field validation
I think the validation api might be a better method, though.
Comment #12
artscoop commentedHello,
indeed, it worked for a date field.
If you need it on a registration form, the form name is user_register. The date field name is usually field_[0], the value is $value[0]['date'].
Comment #13
robby.smith commentedsubscribing
Comment #14
YK85 commentedcan anyone help with this for version 6.x?
Comment #15
robby.smith commentedhaving this feature in 6.x would be very helpful
Comment #16
joachim commentedOn D6, here's the code to put in hook_nodeapi:
or wrapped up as a helper function:
Comment #17
arlinsandbulte commentedAbove is some custom code that can be used to solve this, I think.
More importantly (for D7 at least), a new Field Validation module has been released that looks nice:
http://drupal.org/project/field_validation....
There is a module for that!
So, I am closing this.
Comment #18
jmolinas commentedwhere do i put this code?
thanks
Comment #19
g089h515r806 commentedIf you use Drupal 7, try field validation module, the sub module "date validation" exactly solve this issue.
http://drupal.org/project/field_validation
document for date range validation:
http://drupal.org/node/1438436
Comment #20
alb commented@joachim or who know solution
can explained better how use the code in
hook_nodeapi or wrapped up as a helper function
is necessary to create a module?
which are the steps?
Comment #21
Paul B commentedValidating the date range is rather basic functionality, I should not have to use the field_validation module for that.