# Creating an input time field for Client

**URL:** <https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [June 14, 2018, 6:58pm UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473 "2018-06-14T18:58:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmin](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jmin](https://forum.inductiveautomation.com/u/jmin)\
**Post date:** [June 14, 2018, 6:58pm UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473/1 "2018-06-14T18:58:04Z")

</div>

I was trying to find ways for the client to enter time into a field and I discovered “formatted text field”. On the formatted mask, I put ##:## am this enables the client to put 4 digits, the hour and the minute(if the client enter 1248, it will display as 12:48 am). This is great, but is there a way to restrict the range of number they can put in these #s? I want the first ## to be between 0-12 and the second ## to be between 0-59. If not, what is a good way to implement this?

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [June 15, 2018, 12:08am UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473/2 "2018-06-15T00:08:13Z")

</div>

You could put in a property change script, so that if the value changes and it’s valid, then the value is forwarded to your destination, but if the value changes and it’s invalid, then the value is rejected and reverts back to the previous value.

It might look something like this…

```auto
if event.propertyName == "value":
	#print event.newValue
	newText = event.newValue.split(":")
	value0 = int(newText[0])
	value1 = int(newText[1])
	
	if (0 < value0 <= 12) & (0 <= value1 <= 59):
		system.tag.write("destination tagpath", event.newValue)
	else:
		event.source.text = event.oldValue
```

Also, I might uncheck “Allows Invalid Text”.

---

<div class="post-metadata">

**Author:** ![zacslade](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacslade/32/3587_2.png) [@zacslade](https://forum.inductiveautomation.com/u/zacslade)\
**Post date:** [June 15, 2018, 12:14am UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473/3 "2018-06-15T00:14:34Z")

</div>

Also, attn: Ignition Devs,

I wasn’t able to get the above script to work on a Formatted Text Field by using “text” as the propertyName. I ended up just putting this into my property change script to find out what it was supposed to be:

```auto
if event.oldValue != event.newValue:
	print event.propertyName
```

and this was the output when I changed the value in the text field:

```auto
value
textValid
committedValue
```

but the tooltip on the “text” property in the property editor says that the Property Scripting Name for that property is “text”, and there is no accessible property with the name “value” as far as I can tell.

---

<div class="post-metadata">

**Author:** ![nick.schuetz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick.schuetz/32/6160_2.png) [@nick.schuetz](https://forum.inductiveautomation.com/u/nick.schuetz)\
**Post date:** [June 15, 2018, 1:34pm UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473/4 "2018-06-15T13:34:28Z")

</div>

You could use a Regular expression such as  
`(1[0-2]|[1-9]):[0-5][0-9]`  
or  
`(1[0-2]|[1-9]):[0-5][0-9](\\s)?(?i)(am|pm)`

Description:  
`(1[0-2] #allows 10-12 |[1-9]) #OR allows 1-9 : [0-5][0-9] #allows 00-59 (\\s)?(?i)(am|pm) #allows lower or upper case AM or PM with or without a space`

There are quite a few different variations of time regex patterns. A quick search will give you more options.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 15, 2018, 2:55pm UTC](https://forum.inductiveautomation.com/t/creating-an-input-time-field-for-client/18473/5 "2018-06-15T14:55:19Z")

</div>

The formatted text field with a regular expression is definitely the easiest way to solve this.

> [@zacslade](#):
>
> but the tooltip on the "text" property in the property editor says that the Property Scripting Name for that property is "text", and there is no accessible property with the name "value" as far as I can tell

This looks to be a consequence of the structure of the base JFormattedTextField, but I'll make a note to investigate deeper.
