This topic is locked

Need to validate a date (16 years or more)

2/18/2016 11:35:38 AM
PHPRunner General questions
N
notuo author

Hi. I need to validate for a date.
I want to take advantage of the date data type and the date picker pop up. The issue starts when I don't have any way to specify an own validation routine.
Also, the standard validation doesn't allows to do this. There is a range of years but always has to end this year or past, never before Any attempt to enter a negative number in that part produces an error. (I can present a range of dates but the end date is always greater than today)
The user must be greater than 16 years old. I have the validation routine in JS but I am not able to attach it to this field.
Any idea about how to code this?
Thanks in advance

Sergey Kornilov admin 2/18/2016
N
notuo author 2/18/2016



Use your own validation plugin:

https://xlinesoft.com/phprunner/docs/validation_types.htm#own_validation_type


Thanks for your answer but I tried. There is no way to select any validation in that type of field. In other fields there are a "Validate as" dropdown but no in this data type.
Image of this field properties: https://app.box.com/s/mbg1n2cx8mkse3tacc3xbw1ez3cy4axy
Regards,

Sergey Kornilov admin 2/18/2016

Got it, date picker doesn't offer this sort of additional validation. This designed this way because this is a complicated control and it's not clear when user ends inputting the date and when to run the validation.
You have a few options here.

  1. Use a server side event like BeforeAdd for this purpose.
  2. Do not use datepicker, use set of dropdown boxes to enter the date and set years range.
  3. Use Javascript BeforeSave event:

    https://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm