0
One of the form fields requires the following validation:
It must contain 6 numbers, the last of which must be the result of the sum of the others. If this sum is greater than 10, all digits of the result must be added up 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>";
}
}
Thank you very much! It helped a lot!
– wilhelm andreas
I saw that you are new on the site. You know you have to choose an answer as the favorite?
– Sam
Mark in your favorite answer. Click the icon next to the answer.
– Sam
Took the answer and disappeared, kkk +1
– user60252
In a is? That’s why I already see new users and already pass the tape
– Sam
@wilhelmandreas mark the answer as accepted, see https://i.stack.Imgur.com/evLUR.png
– user60252
@dvd saves this image link so you can use https://i.stack.Imgur.com/evLUR.png
– user60252
@Leocaracciolo From a reputation, I think 15K, becomes "reliable user"... or is 20K, I do not remember
– Sam