Hi,
I have text box input that I have tweaked for taking multiple values and it works fine. I need to limit number of values that a user can insert. How to do this?
Thanks in-advance!!!!
@mbasharat I think the idea is to ensure that original token is not used as is in the final search.
For example
I am sure I would have taken care of above steps in the previous example as well. However, if it is not clear refer to a very basic 9 digit validation answer which should explain these steps better: https://community.splunk.com/t5/Developing-for-Splunk-Enterprise/Textbox-Character-limitation/m-p/52...
Do up vote the original answers as well if they help! 🙂
@mbasharat what do you mean by limiting the number of values? Are values some type of delimited strings? Or are they based on length?
Hi @niketn
It is a text box input on one of my dashboards where user can insert more than on Vulnerability IDs separated/delimited by comma. At the moment, they can insert as many as they want but we need to have this input limited e.g. no more than 10 Vulnerability IDs.
Vulnerability ID is in below format and it is standard:
ABC-2020-1234
When user inputs more than one, it looks like this:
ABC-2020-1234,DEF-2020-1234,GHI-2020-1234 and so on.
If I understand it will need to be character limit to be placed. For example, above three total 41 characters including comma delimiter.
Custom CSS/JS etc. are not the options available or what I am looking for. If an XML code can be done in dashboard, that will be great and lesser maintenance.
Note: I am posted another question referencing one of your solutions in the past for another issue below so if you ca look at this one and guide as well, that will be great. Thanks!!!
@mbasharat I think the idea is to ensure that original token is not used as is in the final search.
For example
I am sure I would have taken care of above steps in the previous example as well. However, if it is not clear refer to a very basic 9 digit validation answer which should explain these steps better: https://community.splunk.com/t5/Developing-for-Splunk-Enterprise/Textbox-Character-limitation/m-p/52...
Do up vote the original answers as well if they help! 🙂
Great. This worked!!! THANK YOU 🙂
@mbasharat So you want to restrict only 10 Vulnerability IDs which are comma delimited. Please refer to one of my previous answers of validating only 5 URLs using an independent search to perform complex validations. The solution is purely Simple XML however, you need to change the validation to pattern match for vulnerability and up to 10 comma separated values instead of 5.
https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-a-text-box-using-condition/t...
This should be straightforward conversion, if not let me know!
Hi @ niketnilay,
I have tweaked and consolidated your provided solution code based on my need and it works perfect to produce validation errors to users.
However, there is one big issue. I am using | search vuln_id IN ($vulnid$) in my search. If a user inserts 11 values instead of limit of 10 in validation check in your solution, validation errors are produced as coded but search still runs for 11 values instead of 10. How to make the search fail unless user inserts 10 values or less?
Thanks and awaiting response.
you can add simple js to your simple xml.
The below JS has two options, either you can limit characters based on input id or all inputs is commented.
Only input which has id "user_text_input" in simple xml will be limited to 9 characters.
require(['jquery','splunkjs/mvc','splunkjs/mvc/simplexml/ready!'], function(){
//Below is based on input ID
$('#user_text_input').find(':input').attr("maxlength", 9);
//Below is for all inputs
//$('input').attr("maxlength", 9);
});
simple.xml
<form script="limittextboxchars.js">
<label>Limit - texbox characters</label>
<fieldset submitButton="false">
<input type="text" id="user_text_input" token="field1">
<label>field1</label>
</input>
<input type="text" token="field2">
<label>field2</label>
</input>
</fieldset>
</form>
Hi @ thambisetty,
Please see my response with additional details to @niketn Thanks in-advance!!!