regular expression with year field

Dear Developers,
I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
E.g. Year <2050.

Many thanks and best wishes,
Padd

Comments

  • GerbenRienkGerbenRienk Posts: 749 ✭✭✭
    Hi Padd,

    Yes, this is possible. You can use a regular expression and this will be validated before the check is fired that the entered characters must form a date.
    So the main part of your regexp must be the year: days and months will be validated by OpenClinica.
    Fill in column V (VALIDATION):
    regexp: /\d\d\-\w\w\w\-(19\d\d|20[0-4]\d)/
    and in column W (VALIDATION_ERROR_MESSAGE)
    Please give a date before 2050.

    If this is not exactly what you want, use http://regexpal.com/ to find out how to get just that.
    Hope this helps,

    Gerben Rienk
    http://www.trialdatasolutions.com

    Van: developers-bounces@openclinica.org [mailto:developers-bounces@openclinica.org] Namens Thatsanun Ngernseng
    Verzonden: woensdag 5 september 2012 9:59
    Aan: developers@openclinica.org
    Onderwerp: [Developers] regular expression with year field

    Dear Developers,
    I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
    E.g. Year <2050.

    Many thanks and best wishes,
    Padd
  • Hi Gerben Rienk,
    Thanks, it worked.

    Padd
    Sent: Tuesday, September 11, 2012 1:55 AM
    To: developers@openclinica.org
    Subject: Re: [Developers] regular expression with year field

    Hi Padd,

    Yes, this is possible. You can use a regular expression and this will be validated before the check is fired that the entered characters must form a date.
    So the main part of your regexp must be the year: days and months will be validated by OpenClinica.
    Fill in column V (VALIDATION):
    regexp: /\d\d\-\w\w\w\-(19\d\d|20[0-4]\d)/
    and in column W (VALIDATION_ERROR_MESSAGE)
    Please give a date before 2050.

    If this is not exactly what you want, use http://regexpal.com/ to find out how to get just that.
    Hope this helps,

    Gerben Rienk
    http://www.trialdatasolutions.com

    Van: developers-bounces@openclinica.org [mailto:developers-bounces@openclinica.org] Namens Thatsanun Ngernseng
    Verzonden: woensdag 5 september 2012 9:59
    Aan: developers@openclinica.org
    Onderwerp: [Developers] regular expression with year field

    Dear Developers,
    I have some issue about regular expression, I would be grateful if the enrollment date(date type) can have some validation rule.
    E.g. Year <2050.

    Many thanks and best wishes,
    Padd
  • JohannaRnstJohannaRnst Posts: 1
    Hello,

    Thanks for the explanation given above. Unfortunately, it seems like my OpenClinica does not like the regex function. I tested it and after implementing the validation (I literally copy-pasted from this thread), I cannot enter any dates without receiving an error message. Would you be able to help with this issue?

    Many thanks and best wishes!

    Hanna
  • GerbenRienkGerbenRienk Posts: 749 ✭✭✭
    Hi Hanna,
    That's strange. I uploaded an example: can you please look for differences with your situation?
    Kind regards,
    Gerben Rienk
  • haenselhaensel Posts: 558 ✭✭
    Hi Hanna

    Is the field type ST or DATE? Using Regex with DATE fields might not work but I didn't tested it on my own.

    Regards,
    Christian
This discussion has been closed.