Splunk Dev

Textbox Character limitation

khumer
Explorer

Couple OF Questions related to Text Box Prompt. 

 

I have a a text box prompt which has the restriction to only accept numeric value up to 9 digits.  The ask is to count the digits while user adding the entry to the text box so users would know how many digits has been added to the box.  I am not able to get around it I know there might be a java script that I can use that can calculate the digits while it is being added to the text box  and show the character count underneath the text box but cannot find the script  online.

 

One other requirement to create a info popup when users puts less than 8 digits when submit button is clicked.   

niketn
Legend

@khumer If you want to handle validation of Text Input through its Change Event Handler (and using an independent search to perform complex validation as per your requirement), you should be able to get to your desired result directly through Simple XML without any JS. Please try the following run anywhere example.

Screen Shot 2020-09-21 at 12.27.37 AM.png

 

<form>
  <label>Text Box Input validation</label>
  <!-- Independent Search to perform strictly 9 digits input validation -->
  <search>
    <query>| makeresults 
| fields - _time 
| eval id="$id$" 
| eval validationNumeric=case(isnum(id) AND NOT match(id,"\."),1,true(),0),
validationLength=case(len(id)=9,1,true(),0)
| eval validatedID=case(validationNumeric==1 AND validationLength==1,id,true(),"failed")
| eval validationMsg=case(validationNumeric==0 AND validationLength==0,"ID must be 9 digit number.",
                    validationNumeric==0,"ID must have only digits.",
                    validationLength==0,"ID must be 9 digits.",true(),"success")</query>
    <earliest>-1s</earliest>
    <latest>now</latest>
    <progress>
      <!-- Clear validation ID if input validation failes -->
      <eval token="validatedID">case($result.validatedID$!="failed",$result.validatedID$)</eval>
      <!-- Clear validation Msg if validation is successful -->
      <eval token="validationMsg">case($result.validationMsg$!="success",$result.validationMsg$)</eval>
    </progress>
  </search>
  <fieldset submitButton="false" autoRun="false"></fieldset>
  <!-- Show Error in case of Input 9 digit validation failure -->
  <row>
    <panel>
      <input type="text" token="id" searchWhenChanged="true">
        <label>Enter Number (*9 digits)</label>
        <change>
          <!-- Every Time Input changes Validation ID and Message will be re-evaluated using Independent search. -->
          <!-- So unset both -->
          <unset token="validatedID"></unset>
          <unset token="validationMsg"></unset>
        </change>
        <default>123456789</default>
      </input>
      <html depends="$validationMsg$">
        <div>
          <div>
            <code>Validation Error: $validationMsg$</code>
          </div>
        </div>
      </html>
    </panel>
  </row>
  <!-- Run search only if Valid 9 digits are keyed in as input -->
  <row depends="$validatedID$">
    <panel>
      <table>
        <search depends="$validatedID$">
          <query>| makeresults
          | eval validatedID=$validatedID$
          </query>
        </search>
      </table>
    </panel>
  </row>
</form>

 

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

thambisetty
SplunkTrust
SplunkTrust

would you be able post your simplexml and js.

————————————
If this helps, give a like below.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...