This is the default behaviour of the jQuery validation plugin as described on this page
In addition, once a field was highlighted as being invalid, it is validated whenever the user types something in the field (option onkeyup).
If you add the option onkeyup set to false then this will cancel this default behaviour as in the snippet below.
Also, the validation plugin has a method for evaluating a single element called element (Details here), which you may want to consider instead of using .valid() on the element.
$(function() {
$("#inputForm").validate({
onfocusout: function(valueToBeTested) {
$(valueToBeTested).valid();
},
onkeyup: false,
rules: {
valueToBeTested: {
required: true,
digits: true,
minlength: 5,
maxlength: 5
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/jquery.validate.js"></script>
<div class="space">
<h1>After the first validation, this reverts from onblur to onchange. Why?</h1>
</div>
<form id="inputForm">
<label class="center" for="valueToBeTested">Enter the number:</label>
<input name="valueToBeTested" type="number" class="center" id="valueToBeTested">
<div id="outputText"></div>
<input type="submit" value="calculate" id="triggerButton" class="center">
</form>