Hi all,
I have an input field on my form that I want to be validated. Pls compare the following:
<div class="form-group">
<label for="insuranceNumber">Versichertennummmer</label>
<div class="controls">
<input required="true"
cam-variable-name="customerNumber"
cam-variable-type="String"
name="customerNumber"
id="customerNumber"
ng-pattern="/^[0-9]{9,9}$/"
class="form-control" />
<p ng-if="insuredPersonForm.customerNumber.$invalid" style="color: red">
Eingegebene Versichertennummmer ist ungültig!
</p>
<p class="help-block" ng-show="insuredPersonForm.customerNumber.$invalid">Versichertennummer muss 9stellig numerisch sein.</p>
</div>
</div>
The idea I got from here: Camunda form validation
My problem is that the invalid paragraphs are shown from the start, when the form is loaded. Even if the input field does not contain any value.
-
Is it possible that the validation is fired only, when I submit the form?
-
I sometimes set the input field via javascript. e.g.
angular.forEach($scope.insuredPersonsList, function(insuredPerson) { if(insuredPerson.id == select.value) { document.getElementById('customerNumber').value = insuredPerson.customerNumber;
then I need to enter the field manually and remove the last sign and add it again. Then the input field is valid. What do I need to do here? Set an attribute dirty or blur or sth?
Thank you