Dashboards & Visualizations

On dashboard, how do I trim the whitespace in a text input field

Dev999
Communicator

This seems a common situation: need to trim the white spaces in a text input box. With html, I can do it inside submit.on("submit"), but it seems a hack, and I need it work with simple xml as well. Could someone share the best approach?

Thanks,
Tony

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

You can try something like this. Instead of using tempToken, use the token defined as actualToken in your searches.

 <input type="text" token="tempToken">
      <label>Specify a log level</label>
      <default>INFO</default>
      <change>
          <!-- use predefined input tokens to set -->        
          <eval token="actualToken">trim("$value$")</set>
      </change>
    </input>

View solution in original post

somesoni2
Revered Legend

You can try something like this. Instead of using tempToken, use the token defined as actualToken in your searches.

 <input type="text" token="tempToken">
      <label>Specify a log level</label>
      <default>INFO</default>
      <change>
          <!-- use predefined input tokens to set -->        
          <eval token="actualToken">trim("$value$")</set>
      </change>
    </input>

Dev999
Communicator

almost there, if I create another textinput, it works perfectly in terms of functionality. there must be a way to hide the actual input. This is certainly the right direction. I appreciate your help.

0 Karma

sloshburch
Ultra Champion

"hide the actual input." you lost me there. Why would you hide the text input if you require the user to input text?

0 Karma

Dev999
Communicator

Got it work with css style. I only need to see one textinput, so the actualToken one should not show on the page.

Thanks a lot!

0 Karma

sloshburch
Ultra Champion

Oh, yea, I wonder if you can just say

<eval token="tempToken">trim("$value$")</set>

so you're not creating multiple. Sounds like you got a solution by playing with it.

0 Karma

Dev999
Communicator

My bad. It does work. No need for a second textinput. Very cool. Thanks!

0 Karma

sloshburch
Ultra Champion

Bingo! @dev999, let us know this works by accepting the answer?

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...