Dashboards & Visualizations

How to Validate Text field Token without Using JavaScript

sravankaripe
Communicator

I have dashboard with text field as an input i want to restrict the users to enter wildcard(*) for that text field.
how can i achieve this in simple Xml without javascript.
please help me with this.

0 Karma

niketn
Legend

You can use text input's change event handler to add a condition block and match value of text box to set/unset required token.

<condition match="$value$!=&quot;*&quot;">

Following is a run-anywhere example using Splunk's internal index

<form>
  <label>Text box input validation</label>
  <fieldset submitButton="false">
    <input type="text" token="selLogLevel">
      <label>Provide Log Level</label>
      <change>
        <condition match="$value$!=&quot;*&quot;">
          <set token="logLevelTok">$value$</set>
        </condition>
        <condition>
          <unset token="logLevelTok"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <table depends="$logLevelTok$">
        <search>
          <query>index=_internal sourcetype=splunkd log_level=$logLevelTok$
|stats count</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
      </table>
      <html rejects="$logLevelTok$">
        <div>
          <p style="color:red;font-weight:bold;font-size:150%;text-align:left;">
          Asterix * not allowed
          </p>
        </div>
      </html>
    </panel>
  </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

kranthimutyala
Path Finder

@Niketnilay
Hi Niket,

I'm looking fro a similar kind of solution, but i have two text box inputs.So i need to Prevent the users from entering wildcard(Asterix) in both the inputs.I have tested the above solution but not sure on how to implement the same for 2 inputs(both being text inputs).If they enter Asterix in any one of the field is accepted but both at the same time is not accepted or we can show a pop-up like "Please enter atleast one input."
Please help.

Thank you in advance.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...