Validate Date Format Before Submitting to Library. - InfoPath Dev
in

InfoPath Dev

Validate Date Format Before Submitting to Library.

Last post 02-04-2014 03:38 AM by wilkies0106aw. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-31-2014 02:10 AM

    Validate Date Format Before Submitting to Library.

     All,

     Using InfoPath and SharePoint 2010.

    Normally I do a very simple data validation against my form and fields, using a button control and simple rules to check that fields aren't blank.  This works very well, is easy to implement and be used by users. However in testing of a new form. The form fell over due to users, being users.

    The user entered text in a date picker control. Yes, the date picker control has red dashes around it, but it's missed by the user. Since I check against the control being blank. The rules things job done. Something is in the field.

    Is there a rule setting I can use, if date is NOT a date -  stop? Otherwise I believe I'm going to have to use a regex pattern. Lots of work for users, being users.

    Thanks

    W 

     

  • 02-04-2014 01:32 AM In reply to

    Re: Validate Date Format Before Submitting to Library.

    Hi,

    If your date picker control is bound to a field that is of "Date" data type and a user enters a non-date value, your form would automatically see that as invalid data and wouldn't allow submit. That's best practice, actually - to make sure that the data type for all date fields are, well, Date.

    If you still want to use a data validation rule to get around this, you can set the condition: [DateField] is not blank and [DateField] does not match pattern \d\d\d\d-\d\d-\d\d (which is a custom pattern). Dates have XML values inf the format yyyy-mm-dd so anything the user enters that is not in that format will be treated as invalid data.

    Hope that helps! 

    Mel Clemente
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 02-04-2014 01:32 AM In reply to

    Re: Validate Date Format Before Submitting to Library.

    Hi,

    If your date picker control is bound to a field that is of "Date" data type and a user enters a non-date value, your form would automatically see that as invalid data and wouldn't allow submit. That's best practice, actually - to make sure that the data type for all date fields are, well, Date.

    If you still want to use a data validation rule to get around this, you can set the condition: [DateField] is not blank and [DateField] does not match pattern \d\d\d\d-\d\d-\d\d (which is a custom pattern). Dates have XML values inf the format yyyy-mm-dd so anything the user enters that is not in that format will be treated as invalid data.

    Hope that helps! 

    Mel Clemente
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 02-04-2014 03:38 AM In reply to

    Re: Validate Date Format Before Submitting to Library.

     Mel,

    Thanks - that seems to work.

    All a little confusing until I stopped thinking because I'm using a UK date format i.e. dd/mm/yyyyy. The only problem I've encountered with the form not submitting (as per best practice) is that information isn't always retained if you click out of the error dialog box that lets you know that the form will not be submitted, hence the validation rule.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.