Skip to main content
Kinetic Community

Password Answer Example

Import Files
Service Item Password Example
KURL Password Example
How to create a password question and set the value to a hidden field.

Description

The answer types for questions in Kinetic Request do not include a type of password. However, this is available as an attribute of the HTML input element - type="password".

Using a text element, you can easily create a password input element, and then add a small amount of custom javascript to get the value and place it into a hidden field before the page is submitted. You could also add logic to the javascript to check for certain characters or to makes sure that two passwords match (not included in the example).

To create the password element, you need to put the HTML of the input element in a Kinetic Text Element. Note that the id given to the input element is important and will be needed in the js to save the value to the hidden question.

<p>
Password <input type="password" name="pwd" id="123456">
</p>

To make this question appear just like the other question, you'll want to add the standard Kinetic classes for the question label, question answer, and question layer.

<p>
<div class="questionLabel">Password</div> <div class="questionAnswer"><input type="password" name="pwd" id="123456"></div>
</p>
passwordStyle.png
 
So the resulting Text element looks like this:
passwordQuestion.png
 
The javascript included in the event (probably a before submit event, but in this example on a click event) to save the answer to a hidden question looks like this:
var answer = document.getElementById('123456').value;
KD.utils.Action.setQuestionValue('hidden password question', answer);
The entered value is pulled out of the password type input using that input's id and placed into the question using the setQuestionValue method.