One of the form fields requires the following validation:
It should contain 6 numbers, the latter being the result of the sum of the others. If this sum is greater than 10, you must add all the figures of the result until the new result meets this requirement. If the sum is 10, the value considered for the sixth number of the "Registration number" is 0.
HTML:
Número de Registro:<br >< input type="text" name="registro" onblur="validaRegistro(this.value)">< div id="m3">< /div>
JavaScript:
function validaRegistro(value) {
var padrao = /^[0-9]+$/;
if (value.match(padrao)){
document.getElementById("m3").innerHTML="<font color='green'>Ok!</font>";
}
else {
document.getElementById("m3").innerHTML="<font color='red'>Campo incorreto</font>";
}
}