Progress bar in a form increase whenever a field get a valid input?

Let’s say you have 5 different inputs, where you have to type in the correct value.

This is a very simple skeleton-code, as an example, of course you will have to modify and expand it, to make it work.

$w.onReady(()=>{
	let multiplier = 10;
	let counter = 0;
	$w('#input1, #input2, #input3, #input4, #input5').onChange(()=>{
		if ($w('#input1').valid) {counter = counter + 1;}
		if ($w('#input2').valid) {counter = counter + 1;}
		if ($w('#input3').valid) {counter = counter + 1;}
		if ($w('#input4').valid) {counter = counter + 1;}
		if ($w('#input5').valid) {counter = counter + 1;}
	});
	$w("#myProgressBar").value = counter*multiplier;
});