We recently implemented a script on our site to capture the time it takes to render an above-the-fold element on our homepage (doing this to measure perceived page load).
We are currently using the custom code below in Adobe DTM's direct call rule to set the time (integer with two decimals) to a numeric custom event. Event2 would be the numeric custom event we want the time value to set to and hpelement would be the data element that retrieves the value from the deployed data layer.
The above setup seems to work out fine except for a couple of instances when the time (in seconds) is set to an insanely high number (e.g. 5 million seconds vs. 4 seconds). When I look at the data in Adobe Analytics, these high numbers seem to be reporting from bot-related traffic (e.g. IP addresses from Google).
My question would be if there's anything I can change in the custom code above that can exclude those high numbers from being set to event2. For example, if the data element has a value of above 10000 then do not set to custom event2.
You also asked this question on Stack Overflow, and you marked my answer as solved, but I may as well post it here too, for posterity.
btripple's answer is basically right in principle, but the condition itself isn't what you are looking for. His condition will return true if the returned data element value is truthy, which is basically any number except zero.