iService will perform input validation for user input when you specify the -required and -confirm parameters. This validation is performed on the server and your page will reload with any error details specified within the $errormessage command. However, If you are using the -customhtml option, the page will reload without the values the user set when they submitted the form. This is only an issue when using the -customHTML option.
You can pass the submitted values returned by the server back to the -customerHTML fields by adding some additional code to the fields that are using -customHTML. This code will update the fields with the information passed back from iService after the validation occurs, preserving whatever the user entered.
To preserve the value of a standard input element, use the HTML value parameter as shown below. This tells the form that if the form reloads to populate the field with whatever value the server received (in this case, the last name supplied when the form was submitted).
$input -id'lastname' -customhtml -required$
<input value="$form -id'lastname'$" name="lastname" type="text" />
The following example illustrates using the $If command to reload a value that was selected in a drop down menu.
<label>I have a question about:</label>
<div>$input -id'requesttype' -required -customhtml$</div>
<select name="requesttype">
<option value="">Please Choose One</option>
<option $if -fieldregex'requesttype'='Product'$selected$endif$ value="Product">Products</option>
<option $if -fieldregex'requesttype'='Service'$selected$endif$ value="Service">Services</option>
<option $if -fieldregex'requesttype'='Other'$selected$endif$ value="Other">Other</option>
</select>
</div>
The same example for a selection using radio buttons is shown below.
<div class="row">
<label>I have a question about a:</label>
<div>$input -id'requesttype' -required -customhtml$</div>
<label class="options inline"><input type="radio" name="requesttype" $if -fieldregex'requesttype'='product'$checked$endif$ value="product" />Product</label>
<label class="options inline"><input type="radio" name="requesttype" $if -fieldregex'requesttype'='service'$checked$endif$ value="service" />Service</label>
<label class="options inline"><input type="radio" name="requesttype" $if -fieldregex'requesttype'='other'$checked$endif$ value="other" />Other</label>
</div>