How to validate a date value even if it's nonsense?

I’m trying to validate that an entered value is a date that is <= today. I was able to do it with a DateTime.Parse() in the Custom OnServerValidate section, but because this validation fires before the form designer’s built-in validation of the date string itself, the .Parse throws an exception in the form if non-date data is entered. DateTime.TryParse() cannot be used there, because it requires more than one line and WFG is injecting the statement into a single if bracket. I even tried writing a method in code behind to handle the logic, but I’m not sure how to call my method from the form designer. I suppose I could create a validator dynamically in code behind, but there must be a simpler way to do this within form designer?

Hi,

Kindly open a ticket in Helpdesk so we can assist you in solving this issue.

Best Regards,
Eddy.

Hi Eddy,
I have a similar issue also, just wondering if a solution found? Thank you,
Rogelio

I had to use a custom validator inserted dynamically from cold behind. One disadvantage is that it can’t utilize the popup dialogue that the rest of the form designer validators use, because I couldn’t find a way to integrate it into the form designer specific validator system. So, it I just used display=dynamic and it shows up as red text next to the form field. This is a pretty basic use case that the form designer should be updated to handle.

See here for details: How to use a .NET CustomValidator control with server-side validation

Hi everyone,

I just tried it and the easiest solution for me was to use another field to do the validation.

Created a simple form and in this case, the Description Textbox validates the DateTime field.

Let me know if this meets your needs.

Best Regards,
Eddy.

Thank you esanford and eddy!