<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Textbox Validation Issue in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319748#M161379</link>
    <description>&lt;P&gt;Yeah bro, I have used the same thing and restart the splunk and used the _bump also. &lt;/P&gt;

&lt;P&gt;But its not working. Nothing is happening.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2017 13:34:10 GMT</pubDate>
    <dc:creator>vivek_manoj</dc:creator>
    <dc:date>2017-04-12T13:34:10Z</dc:date>
    <item>
      <title>Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319742#M161373</link>
      <description>&lt;P&gt;I am trying to validate the testbox to accept only numeric not any other character. How to do that?&lt;BR /&gt;
Thanks in Advance.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 09:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319742#M161373</guid>
      <dc:creator>vivek_manoj</dc:creator>
      <dc:date>2017-04-12T09:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319743#M161374</link>
      <description>&lt;P&gt;Hi vivek_manoj,&lt;BR /&gt;
I think that it's not possible to do this!&lt;BR /&gt;
if you haven't high numbers you could use as workaround a dropdown list, but obviously it isn't the same think!&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 10:03:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319743#M161374</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-04-12T10:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319744#M161375</link>
      <description>&lt;P&gt;Have a look at this blog entry from Splunk: &lt;A href="https://www.splunk.com/blog/2016/09/21/using-html5-input-types-on-splunk-forms/"&gt;https://www.splunk.com/blog/2016/09/21/using-html5-input-types-on-splunk-forms/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This will point you in the right direction.&lt;/P&gt;

&lt;P&gt;Just to summarize the recommendations from the mentioned post: You have to include the following code fragments:&lt;/P&gt;

&lt;P&gt;In your dashboard, include a custom JavaScript File like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="set_input_types.js"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add an id to the XML code of the field to be validated:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="numbers" id="numbers_only" searchWhenChanged="true"&amp;gt;
    &amp;lt;label&amp;gt;Numbers only&amp;lt;/label&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Create a .js file in your app's &lt;CODE&gt;appserver/static&lt;/CODE&gt;directory, named &lt;CODE&gt;set_input_types.js&lt;/CODE&gt; (or the name you assigned in the dashboard). Then include this code in the .js:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require(["jquery", "splunkjs/mvc/simplexml/ready!"], function($) {
    $("[id^=numbers_only]").attr('type','number')
}); 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will provide a HTML5 number input field. You will have to restart the splunk server (or reload it) for the changes to take effect.&lt;/P&gt;

&lt;P&gt;Please note - this will only work in fully HTML5 compatible browsers.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 10:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319744#M161375</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2017-04-12T10:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319745#M161376</link>
      <description>&lt;P&gt;Its not working. Its showing nothing.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 11:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319745#M161376</guid>
      <dc:creator>vivek_manoj</dc:creator>
      <dc:date>2017-04-12T11:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319746#M161377</link>
      <description>&lt;P&gt;Can you please post the code you have implemented? It is quite hard to debug your errors if we don't know what you have coded.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 12:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319746#M161377</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2017-04-12T12:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319747#M161378</link>
      <description>&lt;P&gt;Another addition: I have edited the original answer to clarify the steps you have to take. Please verify.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 12:59:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319747#M161378</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2017-04-12T12:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319748#M161379</link>
      <description>&lt;P&gt;Yeah bro, I have used the same thing and restart the splunk and used the _bump also. &lt;/P&gt;

&lt;P&gt;But its not working. Nothing is happening.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 13:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319748#M161379</guid>
      <dc:creator>vivek_manoj</dc:creator>
      <dc:date>2017-04-12T13:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319749#M161380</link>
      <description>&lt;P&gt;Convert your page to HTML, set an id to your input textbox like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="text" token="numbers" id="numbers_only"&amp;gt;
     &amp;lt;label&amp;gt;Numbers only&amp;lt;/label&amp;gt;
 &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;..then put this in script below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$(document).ready(function() {
    $('#numbers_only').on('keyup', function() {
        if (/^\d+$/.test($(this).val())) {
            // Contain numbers only   (do something if contains only numbers)
        } else {
             //do something if contains nonumeric
            alert('nonnumbers')
        }
    })
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;..and that should work and check on every keyup in text input&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 14:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319749#M161380</guid>
      <dc:creator>loggar</dc:creator>
      <dc:date>2017-04-12T14:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319750#M161381</link>
      <description>&lt;P&gt;Hi Loggar,&lt;/P&gt;

&lt;P&gt;I tried and I am attaching the snapshot of the code. Please look into it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;

  &amp;lt;row&amp;gt;
  &amp;lt;panel&amp;gt;
    &amp;lt;html&amp;gt;
      &amp;lt;script&amp;gt;
      $(document).ready(function() {
     $('#numbers_only').on('keyup', function() {
         if (/^\d+$/.test($(this).val())) {
             // Contain numbers only   (do something if contains only numbers)
         } else {
              //do something if contains nonumeric
             alert('nonnumbers')
         }
     })
 });
      &amp;lt;/script&amp;gt;
     &amp;lt;input type="text" token="numbers" id="numbers_only"&amp;gt;
      &amp;lt;label&amp;gt;Numbers only&amp;lt;/label&amp;gt;
  &amp;lt;/input&amp;gt;
    &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:00:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319750#M161381</guid>
      <dc:creator>vivek_manoj</dc:creator>
      <dc:date>2017-04-12T19:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319751#M161382</link>
      <description>&lt;P&gt;@vivek_manoj You can use change event handler for text box and within the same you can use eval with match to accomplish numeric field validation. Following is run anywhere code and needless to say it is Simple XML, without the need for HTML or JS.&lt;/P&gt;

&lt;P&gt;Following statement should do the trick for you: &lt;CODE&gt;&amp;lt;eval token="validationResult"&amp;gt;if(match(value, &amp;amp;quot;^[0-9]+$&amp;amp;quot;), &amp;amp;quot;Numeric&amp;amp;quot;, &amp;amp;quot;Not Numeric&amp;amp;quot;)&amp;lt;/eval&amp;gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You can try more complex regular expression validation like decimal, negative etc based on your use case. Following is only for digits 0 to 9.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;TextBox Numeric Validation&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="selText"&amp;gt;
      &amp;lt;label&amp;gt;Enter Only Digits&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="validationResult"&amp;gt;if(match(value, &amp;amp;quot;^[0-9]+$&amp;amp;quot;), &amp;amp;quot;Numeric&amp;amp;quot;, &amp;amp;quot;Not Numeric&amp;amp;quot;)&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
 | eval Text="$selText$ is $validationResult$" 
 | table Text&amp;lt;/query&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319751#M161382</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-12T19:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Textbox Validation Issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319752#M161383</link>
      <description>&lt;P&gt;@vivek_manoj, I am not sure whether you had tried the run anywhere dashboard example for text box JavaScript Validation. Can you please check and confirm? This is purely Simple XML hence does not require JavaScript or Reboot/Refresh/Bump of Splunk.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Oct 2017 16:42:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Textbox-Validation-Issue/m-p/319752#M161383</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-28T16:42:35Z</dc:date>
    </item>
  </channel>
</rss>

