Time entry

B

Bobc7

Is there a way of saving users from entering the colon ":" in a time entry.
eg if they input 0700 it will default to 07:00.

Thanks
 
G

Greg Collins [InfoPath MVP]

If you are using a time field, you could use "7a" to get 07:00...

Well, I just did a quick check... it looks like you can use the "." character in place of ":" and InfoPath converts it correctly... so if I type in 7.15 it changes it to 7:15 for me. Cool!

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Is there a way of saving users from entering the colon ":" in a time entry.
eg if they input 0700 it will default to 07:00.

Thanks
 
D

Deb

S.Y.M:

Can this solution be modified to format a telephone number such that if the
user enters 10 digits it is formatted as: 999 999-9999?

I changed the formula on the helperfield to:

concat(substring(txtContactPhone, 1, 3), " ", substring(txtContactPhone, 4,
6), "-", substring(txtContactPhone, 7, 10))

So if the user enters 1234567890 it should format it as 123 456-7890

But, it's formatting it as:
123 456789-7890

Is that because you can't have five arguments in the concat function?

Thanks!
 
S

S.Y.M. Wong-A-Ton

You've almost got it, girl! Try

concat(substring(txtContactPhone, 1, 3), " ", substring(txtContactPhone, 4,
3), "-", substring(txtContactPhone, 7, 4))

You can have as many arguments as you like (there is probably a limit, but I
haven't found it yet) in the concat() function.

Handy scenario! I'll create a recipe and post it on my website this weekend.
 
D

Deb

AWESOME! I've been searching high and low for this solution.

Can you explain a little about the concept of the helperfield and why it's
necessary?

Thanks so much for your help!
 
S

S.Y.M. Wong-A-Ton

Great question, Deb! It got me thinking and trying new things...

You're right, it's not required. You can also just create a rule on the
field to set its own value. The problem with doing this is that the rule will
run whenever the value changes, which is what you would be doing by setting
its value with a formula, so the rule will keep on running and keep on
changing the field until it cannot change it anymore. You can prevent this
recursive changing by adding a condition on the rule. I'll show you how to do
this in the solution I'm going to post this weekend and correct the other
solution I already had on my website.

The helperField is still good to use e.g. when you need an "outsider" field
to do processing on a repeating field that a repeating field cannot do itself.

Thanks for the question!
 
D

Deb

Well, it works and I'm not complaining. ;-) I needed it for two telephone
fields so had to create two helper fields. The only catch is that if we trap
the \d{10} pattern, I don't know of a way to validate the user enters this.
I tried a validation that looked for \d{10} OR the combination that would
result in 999 999-9999 since that's what the logic is doing to the value --
anything else should be wrong. That didn't work, though, as it never let me
out of the error condition for some reason. Anyway, I thought the solution
was good from a user experience; i.e., the user can just type numbers and
they're automatically formatted, or they can format them theirself and their
formatting is left alone. Probably not a good solution where the format of
the data is important, but in my case it's not. I just wanted the user
experience to be easy.

Thanks for your brilliance! Will you be sure to re-post here when you have
the new solution so I can go study it? I'm relatively new to InfoPath and am
floundering in understanding functions, events, methods, XPath, ... <gulp>.

Deb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top