Skip to main content
13-Aquamarine
Jun 21, 2023 7:00 AM UTC
Solved

How to enable button when we just enter the value in numeric entry widgets in thingworx.

On mashup Load:

Hrishab108_0-1687330453844.png

we entry the value numeric entry box the button is not enabled

Hrishab108_1-1687330543119.png

When i click outside the numeric box the button is enabled 

but i want that the button should be enabled as soon as we enter the value. Not need to click outside or around them.

Hrishab108_0-1687332107832.png

 



 

 

12-Amethyst
Jun 22, 2023 7:03 AM UTC

I did an quick and dirty approach here. There are still some cases that are not taken into account here. Just like negative decimals etc. What happens if an user enter "alphabetic" values or several "." or ","...

I think this should be enough as a starting point 😉

 

if (NumericEntry == undefined || NumericEntry == null || NumericEntry == "" || NumericEntry == "NaN" || NumericEntry == "0") {
	Output = "0";
} else {
	NumericEntry = NumericEntry.replace(/,/g, ".");
	if (!NumericEntry.includes(".")) {
		Output = NumericEntry.replace(/^0+/, '');
	} else {
		Output = NumericEntry;
	}
}

 

Do not use the auto-evaluate of the expression. Use the changed event instead.

Markus_Neini_0-1687417196939.png

The UI should look like.

 Markus_Neini_1-1687417209615.png

3 replies

12-Amethyst
Jun 21, 2023 7:36 AM UTC

Hi Hrishab,

depening on your ThingWorx version  I suggest, that you use the normal TextField-Widget and apply some "9999" in the mask field (On TWX version 9.4 the mask property is not working as expected anymore). So your user just can type numerical entries in your field. It also will refresh your value on every text changed event.

The problem with that workaround is that you can have leading zeros and cant type an "," or "." for decimals.

You could also apply some expression that "cleans" the inserted value, whenever the text changes. => remove leading zeros or allow just one ","/".".

Markus_Neini_0-1687332488713.png

I hope I could help you out 🙂

 

Best regards

Markus

 

 

Translate
13-Aquamarine
Jun 22, 2023 12:52 AM UTC

pls can you provide me the expression?

Translate
12-Amethyst
Jun 22, 2023 7:03 AM UTC

I did an quick and dirty approach here. There are still some cases that are not taken into account here. Just like negative decimals etc. What happens if an user enter "alphabetic" values or several "." or ","...

I think this should be enough as a starting point 😉

 

if (NumericEntry == undefined || NumericEntry == null || NumericEntry == "" || NumericEntry == "NaN" || NumericEntry == "0") {
	Output = "0";
} else {
	NumericEntry = NumericEntry.replace(/,/g, ".");
	if (!NumericEntry.includes(".")) {
		Output = NumericEntry.replace(/^0+/, '');
	} else {
		Output = NumericEntry;
	}
}

 

Do not use the auto-evaluate of the expression. Use the changed event instead.

Markus_Neini_0-1687417196939.png

The UI should look like.

 Markus_Neini_1-1687417209615.png

Translate