Date validation problem - InfoPath Dev
in

InfoPath Dev

Date validation problem

Last post 02-15-2007 08:28 AM by MylesRip. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-15-2007 07:22 AM

    Date validation problem

    I'm using a date picker, but a date can be entered directly so I have to validate it. I tried a couple of different regular expressions as custom patterns, but InfoPath thinks data is invalid even when it is valid.

    Also, the field is not required so leaving it blank should also be considered valid. This is a second issue I need to address, ie. making the whole pattern optional.

    Back to the first issue, this is what I tried:

    (0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/(19|20)\d\d

    InfoPath considered this valid and displayed an Example based on this pattern of "01/01/1900". I used the "does not match pattern" option so that anything that doesn't match this pattern will be considered invalid. The result is that everything is considered invalid, even proper dates in the above format.

    I also tried:

    \d\d?/\d\d?/\d\d\d\d

    InfoPath considered this valid and displayed an Example based on this pattern of "00/00/0000". Valid dates are still considered invalid (along with everything else).

    Please help! Thanks in advance!

  • 02-15-2007 07:42 AM In reply to

    Re: Date validation problem

    Hi MylesRip,

    in my opinion the datepicker control validates automatically if you have entered the date in a correct syntax. It is the same than having a regular textbox for which you have the data type set as date. When you enter a date which is not valid InfoPath puts a red dashed border around the control and shows you via a tooltip (hover over the control with your mouse pointer) how you have to enter the date. As long as the form is in that red dashed border status you won't be able to submit it.

    Does this help ?
    Listen to Motörhead cos they play Rock'n Roll :)
  • 02-15-2007 07:58 AM In reply to

    Re: Date validation problem

    Thanks for the quick reply! The date picker is bound to an element in an XmlDocument that is returned from a web service. The element is defined as text. When I go to the properties for the date picker, the data type is set to "string" and the field is grayed out so that I can't change it. The "Format..." options are set to display the date only (I'm using web forms compatibility.) according to the system settings, which in my case is "mm/dd/yyyy". If I do not specify any validation, I can enter "abcd" in the date picker field and it accepts this as valid, ie. no red border.
  • 02-15-2007 08:15 AM In reply to

    Re: Date validation problem

    Then I propose that you take care of the correct syntax in a previous step (e.g. when the web service writes the xml) cos I guess it will be easier to manipulate your "date string" with code rather than using data validation or rules within infopath.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 02-15-2007 08:28 AM In reply to

    Re: Date validation problem

    I had considered that, but the problem is that this is an updatable data source, so the data entered by the user has to be validated as well as the data returned by the initial query. Validating the data at the web service layer when the data is submitted means an extra round trip. (I'm developing this for web use only.) Also, the main reason I decided to use InfoPath for the development was the front-end validation capabilities and the fact that most validation could be done on the browser client without requiring a postback. It appears that it should be able to perform the validation I want by following the steps that I have. If the custom pattern validation worked correctly, I would have no problem. I think this is a bug in InfoPath.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.