<?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: How to add validation on form dashboard input textfield? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164605#M10118</link>
    <description>&lt;P&gt;hey Luke,&lt;BR /&gt;
I tried this before. I don't know why but got a token alert works. But Val() function doesn't work. that alert is not launched at all. Apparently JS fails to compile at that line. I keep searching, thanks for response.&lt;/P&gt;</description>
    <pubDate>Fri, 16 May 2014 18:00:35 GMT</pubDate>
    <dc:creator>axl88</dc:creator>
    <dc:date>2014-05-16T18:00:35Z</dc:date>
    <item>
      <title>How to add validation on form dashboard input textfield?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164603#M10116</link>
      <description>&lt;P&gt;thanks all in advance for your time.&lt;BR /&gt;
I am trying to create a field validation on my dashboard. My fieldset on dashboard is following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset autoRun="true" submitButton="true" &amp;gt;  
&amp;lt;input type="text" token="startdate" searchWhenChanged="true" name="sdate" id="sdate"&amp;gt;
  &amp;lt;placeholder&amp;gt;Last Month&amp;lt;/placeholder&amp;gt;
  &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
  &amp;lt;label&amp;gt;Select a Start Date:&amp;lt;/label&amp;gt;
&amp;lt;/input&amp;gt;
&amp;lt;/fieldset&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I am trying to retrieve values from my dashboard with the following JS code in app/static directory:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var unsubmittedTokens = mvc.Components.get('default');
var submittedTokens = mvc.Components.get('submitted');
var urlTokens = mvc.Components.get('url');
var startDate = mvc.Components.get('sdate');
submittedTokens.on('change:startdate', function(){
    // When the token changes...
    if(!submittedTokens.get('startdate')) {
        alert("no token");
    } else {
        alert("got a token");
        var startdate = document.getElementsByName('sdate').value;
        alert(startdate);
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I couldn't start my validation functions since somehow I can't get value of the field to JS.&lt;BR /&gt;
I want my validation to work in input textfields whenever a field value changes.&lt;BR /&gt;
I can get value "undefined" with getelementbyName function above. But I can't get what user entered into textfield.&lt;/P&gt;

&lt;P&gt;I would be appreciated if someone can help me with above, moreover, if there is an easier way to validate fields on form-Dashboard, you could share it as well. &lt;/P&gt;

&lt;P&gt;I m a new splunker, thanks again for your time&amp;amp;efforts.&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2014 21:08:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164603#M10116</guid>
      <dc:creator>axl88</dc:creator>
      <dc:date>2014-05-14T21:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to add validation on form dashboard input textfield?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164604#M10117</link>
      <description>&lt;P&gt;Try getting the value using "mvc.Components.get("sdate").val()". Thus, your code should look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var unsubmittedTokens = mvc.Components.get('default');
var submittedTokens = mvc.Components.get('submitted');
var urlTokens = mvc.Components.get('url');
var startDate = mvc.Components.get('sdate');
submittedTokens.on('change:startdate', function(){
    // When the token changes...
    if(!submittedTokens.get('startdate')) {
        alert("no token");
    } else {
        alert("got a token");
        var startdate = mvc.Components.get("sdate").val();
        alert(startdate);
    }
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 May 2014 16:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164604#M10117</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2014-05-15T16:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to add validation on form dashboard input textfield?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164605#M10118</link>
      <description>&lt;P&gt;hey Luke,&lt;BR /&gt;
I tried this before. I don't know why but got a token alert works. But Val() function doesn't work. that alert is not launched at all. Apparently JS fails to compile at that line. I keep searching, thanks for response.&lt;/P&gt;</description>
      <pubDate>Fri, 16 May 2014 18:00:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164605#M10118</guid>
      <dc:creator>axl88</dc:creator>
      <dc:date>2014-05-16T18:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to add validation on form dashboard input textfield?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164606#M10119</link>
      <description>&lt;P&gt;Did you find a solution to this issue? I am having the same problem getting val() to work.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2015 15:01:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-add-validation-on-form-dashboard-input-textfield/m-p/164606#M10119</guid>
      <dc:creator>nadine_wondem</dc:creator>
      <dc:date>2015-02-27T15:01:44Z</dc:date>
    </item>
  </channel>
</rss>

