locked
Text control bound to Time field defaults to "12 AM" each time you enter "12" RRS feed

  • Question

  • I have and InfoPath 2007 form that has a text field, bound to a Time field, with format set to "9:46 AM".

    When tesing the form I can enter '0', ''0:00' or '12AM' in the text field and InfoPath automatically (and correctly) converts these values to '12:00 AM' ,'12:59 AM'.  

    Howerver if I enter '12', '12:30', InfoPath converts these to '12:00 AM' and '12:30 AM' respectively.   This becomes a problem, since our users expect '12', '12:30' to mean '12:00 PM' to '12:30PM'.

    To enter the PM time we are forced to type '12 PM' or "12:30 PM', and InfoPath to render the correct time. 

    But users can get careless, typing '12' for noon and not notice that wrong time.

    Does anyone have a solution for this?

    NOTE: I'm working on InfoPath 2007, but this behaviour is the same in InfoPath 2010.

    Thx.

    Friday, April 1, 2011 1:28 PM

Answers

  • This is NOT 24 hour time.  I am requried to include AM/PM on the time field. 

    The problem wit this format is that when a user enters either 0:00 or 12:00, InfoPath automatically converts the entry to 12 AM.

    Your are correct that if a user types '12AM' or '12PM' then the time is correctly entered.  But I'm programming for dummies.  What are the odds that a user types a '12' (meaning noon), then skip to the next box without double checking. 

    I would love to override this this one case where a user types in anything starting with '12'.


    The odds are the same as someone choosing am vs. pm in any other applications, including ones they user every day like Outlook.  I am not seeing why this is different.

    If you must do this in a manner unlike other applications they use, then you have the option of adding a conditional rule to the time field to PM if it starts with 12.  Something like: If TimeField starts with 12 and contains AM, then set field to the same time value of PM.  Another method would be a validation rule that says "If time is less than 8am and greater than 8pm, then show error."  This method would show a red dashed border around the field so that they notice it is an unintended time, but if they really wanted to do a time outside this range, it wouldn't let them - you have to decide just how much logic you want to put into making people's decisions for them.  I personally think they should just choose AM or PM like they do everywhere else.  You can even provide them a dropdown that has all values from 12am to 11pm in a dropdown to make it easy, then let them fill out the minutes or have another dropdown for 15/30/45/00.  Lots of options.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    • Marked as answer by Wayne Fan Monday, April 11, 2011 3:17 AM
    Wednesday, April 6, 2011 1:36 AM

All replies

  • That is the correct behavior unless you set your time settings to 24-hour.  This really is a training issue.  People need to specify AM or PM just like they would in any other form of correspondence.  When you create a meeting invite, you always select AM or PM after selecting "12."  If you type a time in an email, you also type AM or PM.  Why is the behavior expected to be different?  Do all your users expect military time?  I ask that, because that's the only way 12 could be noon is if using military time (24-hour clock).
    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    Saturday, April 2, 2011 2:08 AM
  • This is NOT 24 hour time.  I am requried to include AM/PM on the time field. 

    The problem wit this format is that when a user enters either 0:00 or 12:00, InfoPath automatically converts the entry to 12 AM.

    Your are correct that if a user types '12AM' or '12PM' then the time is correctly entered.  But I'm programming for dummies.  What are the odds that a user types a '12' (meaning noon), then skip to the next box without double checking. 

    I would love to override this this one case where a user types in anything starting with '12'.

     

     

    Tuesday, April 5, 2011 8:50 PM
  • This is NOT 24 hour time.  I am requried to include AM/PM on the time field. 

    The problem wit this format is that when a user enters either 0:00 or 12:00, InfoPath automatically converts the entry to 12 AM.

    Your are correct that if a user types '12AM' or '12PM' then the time is correctly entered.  But I'm programming for dummies.  What are the odds that a user types a '12' (meaning noon), then skip to the next box without double checking. 

    I would love to override this this one case where a user types in anything starting with '12'.


    The odds are the same as someone choosing am vs. pm in any other applications, including ones they user every day like Outlook.  I am not seeing why this is different.

    If you must do this in a manner unlike other applications they use, then you have the option of adding a conditional rule to the time field to PM if it starts with 12.  Something like: If TimeField starts with 12 and contains AM, then set field to the same time value of PM.  Another method would be a validation rule that says "If time is less than 8am and greater than 8pm, then show error."  This method would show a red dashed border around the field so that they notice it is an unintended time, but if they really wanted to do a time outside this range, it wouldn't let them - you have to decide just how much logic you want to put into making people's decisions for them.  I personally think they should just choose AM or PM like they do everywhere else.  You can even provide them a dropdown that has all values from 12am to 11pm in a dropdown to make it easy, then let them fill out the minutes or have another dropdown for 15/30/45/00.  Lots of options.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    • Marked as answer by Wayne Fan Monday, April 11, 2011 3:17 AM
    Wednesday, April 6, 2011 1:36 AM