<?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 Splunk JavaScript help in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571656#M10147</link>
    <description>&lt;P&gt;I have a dashboard , where I want some help in developing&amp;nbsp; a java script that will perform validation on my field.&lt;BR /&gt;I have a field named 'url'. I want users to input only values that doesn't have any padded spaces in the starting or ending and it shouldn't also contain&amp;nbsp; &amp;lt;doublequote&amp;gt;".&lt;BR /&gt;I could use some help in building a Java Script to achieve this.&lt;BR /&gt;&lt;BR /&gt;So, far I have created a field ID&lt;/P&gt;&lt;PRE&gt;&amp;lt;input type="text" token="url" id="url_value" searchWhenChanged="true"&amp;gt;    &amp;lt;label&amp;gt;URL&amp;lt;/label&amp;gt;&amp;lt;/input&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In the Splunk XML I have invoked the .js file&lt;/P&gt;&lt;PRE&gt;&amp;lt;form script="validate the field.js"&amp;gt;&lt;/PRE&gt;&lt;P&gt;I do need some help in writing the javascript that could check for padded spaces in starting or beggining and also to check for " double quote . So that user would avoid inputing this things in the field.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;require(["jquery", "splunkjs/mvc/simplexml/ready!"], function($) {&lt;BR /&gt;$("[id^=url_value]")&lt;BR /&gt;.attr('type','number')&lt;BR /&gt;&lt;BR /&gt;....don't know what next to write here in the .js&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 13:15:52 GMT</pubDate>
    <dc:creator>zacksoft_wf</dc:creator>
    <dc:date>2021-10-20T13:15:52Z</dc:date>
    <item>
      <title>Splunk JavaScript help</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571656#M10147</link>
      <description>&lt;P&gt;I have a dashboard , where I want some help in developing&amp;nbsp; a java script that will perform validation on my field.&lt;BR /&gt;I have a field named 'url'. I want users to input only values that doesn't have any padded spaces in the starting or ending and it shouldn't also contain&amp;nbsp; &amp;lt;doublequote&amp;gt;".&lt;BR /&gt;I could use some help in building a Java Script to achieve this.&lt;BR /&gt;&lt;BR /&gt;So, far I have created a field ID&lt;/P&gt;&lt;PRE&gt;&amp;lt;input type="text" token="url" id="url_value" searchWhenChanged="true"&amp;gt;    &amp;lt;label&amp;gt;URL&amp;lt;/label&amp;gt;&amp;lt;/input&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In the Splunk XML I have invoked the .js file&lt;/P&gt;&lt;PRE&gt;&amp;lt;form script="validate the field.js"&amp;gt;&lt;/PRE&gt;&lt;P&gt;I do need some help in writing the javascript that could check for padded spaces in starting or beggining and also to check for " double quote . So that user would avoid inputing this things in the field.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;require(["jquery", "splunkjs/mvc/simplexml/ready!"], function($) {&lt;BR /&gt;$("[id^=url_value]")&lt;BR /&gt;.attr('type','number')&lt;BR /&gt;&lt;BR /&gt;....don't know what next to write here in the .js&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 13:15:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571656#M10147</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2021-10-20T13:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JavaScript help</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571685#M10148</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237518"&gt;@zacksoft_wf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form script="a.js"&amp;gt;
  &amp;lt;label&amp;gt;Url Validation&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="tkn_url" id="tkn_url_id"&amp;gt;
      &amp;lt;label&amp;gt;URL&amp;lt;/label&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a.js&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
    'underscore',
    'splunkjs/mvc',
    'jquery',
    "splunkjs/mvc/simplexml/ready!"
], function(_, mvc, $) {
    var tkn_url = splunkjs.mvc.Components.getInstance("tkn_url_id"); // your multiselect id here
    tkn_url.on("change", function(e) {
        console.log(e)
            // e.preventDefault();
        if (!isUrlValid(e)) {
            alert("Enter Valid URL")
            return false;
        }
    })

    function isUrlValid(userInput) {
        console.log(userInput)
        var res = userInput.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&amp;amp;//=]*)/g);
        if (res == null)
            return false;
        else
            return true;
    }

})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一 &amp;nbsp; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 15:52:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571685#M10148</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-10-20T15:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JavaScript help</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571797#M10149</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Hi Kamlesh,&lt;BR /&gt;I see the line&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;userInput.match(&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;The regex inside it appears to be matching with a URL field ..starting with Https:/ etc...&lt;BR /&gt;But in my case the URL field has a different meaning , the field could contain any string , it doesn't necessarily have to be a web url address.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;Can we modify the regex , so that it matches for&lt;BR /&gt;&amp;nbsp;- no space padded&amp;nbsp; in the beginning of the string&lt;BR /&gt;- no space padded in the end of the string&lt;BR /&gt;- There should&amp;nbsp; not be any double quotes sign "&amp;nbsp; entered in the string.&lt;BR /&gt;&lt;BR /&gt;If any of the above matches, it should prompt the user to re-enter the value.&amp;nbsp;&lt;BR /&gt;User should keep in mind not to enter strings with spaces in front or end or add any " sign in the input string.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 11:27:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571797#M10149</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2021-10-21T11:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JavaScript help</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571814#M10150</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237518"&gt;@zacksoft_wf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example code, you can change the validation Logic as per your requirements. Just use this code in your JS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 13:25:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/571814#M10150</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-10-21T13:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk JavaScript help</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/574166#M10151</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp;How do I stop the dashboard button from submitting, if there is a validation error message ?&amp;nbsp; I get the validation error message , But even if I don't fix the entry, it still allows me to submit that record.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 11:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-JavaScript-help/m-p/574166#M10151</guid>
      <dc:creator>zacksoft_wf</dc:creator>
      <dc:date>2021-11-09T11:08:44Z</dc:date>
    </item>
  </channel>
</rss>

