Rule check for hours taken off - decimal check - InfoPath Dev
in

InfoPath Dev

Rule check for hours taken off - decimal check

Last post 06-24-2009 10:58 AM by barmatt80. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 06-10-2009 11:03 AM

    Rule check for hours taken off - decimal check

    I have a hours field that is a decimal data type, and users are only suppose to take hours in quarter hour increments.  so 4.00, 4.25, 4.50, and 4.75 are acceptable values (of course they can take more or less hours than 4).  I just need to check the 2 digits after the decimal place to be 0,00,25,5,50,75 ?

    I tried rules with the expression substring after(hours, ".") but still can't get it.

     Suggestions?  Thanks.

  • 06-10-2009 12:12 PM In reply to

    Re: Rule check for hours taken off - decimal check

    This is just a guess, so forgive me if I'm off base.  Do you need to convert hours to a string first?  When you say you can't get it, what exactly is the result?  Are you getting an error, or is it just not catching errors?  Can you post exactly what your rule says?

    -- Kelley
  • 06-10-2009 03:15 PM In reply to

    Re: Rule check for hours taken off - decimal check

    I'm also just taking a wild guess at what you want... but if want you want is data validation on the field they are entering hours on to prevent them putting in anything but numbers ending in .0, .00, .25, .5, .50, .75 you can add data validation to the field. Under the properties of the field, select Data Validation. For the first drop down select the field that you are concerned with. For the second, select 'does not match the pattern'. For the third, paste a custom pattern in:

    \d*\.?((25)|(50)|(5)|(75)|(0)|(00))

    I've created a simple sample and attached it to this post. Right click the link in the header and select Save As to save the template locally. Right click the saved file and select Design to open the form in design mode. Preview the form and try typing different numbers into the box.

    Hilary Stoupa

  • 06-11-2009 09:34 AM In reply to

    Re: Rule check for hours taken off - decimal check

    this is awesome!  Your example worked perfect.

     Data validation is probably one of the less used features I use in infopath.  I usually set rules, give an error message and reset the field.

     I do have one question. The number field in your example.  If i format to have 2 decimal places, it still works great.  What about if a user enters 5 instead of 5.00  or 5.0  ?  how would you get that to work when entering just full hours without specifying the decimal holders.

    I tried adding another pipe and then (" ") or ( ), but didn't work.

     Thanks again, I greatly appreciate the help.  Now I need to learn more on the data validation and expressions in infopath.

  • 06-11-2009 12:56 PM In reply to

    Re: Rule check for hours taken off - decimal check

    Just add another ? at the end of the expression -- we have a ? at the end of \. to show that it may or may not have a decimal. Adding a ? at the end says we may or may not have '25', '5', etc.

    So like:

    \d*\.?((25)|(50)|(5)|(75)|(0)|(00))?

    Hilary Stoupa

  • 06-24-2009 10:58 AM In reply to

    Re: Rule check for hours taken off - decimal check

    Thanks!  I lost my bookmark to here. 

     

     

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