percentage completed form javascript - version 2

1:12 am, May 8, 2018
this will show the percentage (%) that a form has been completed by counting the element that have been completed and calculating the percentage. use the element change to fire the function and calculate the percentage. this one will show the % completed when the form elements are filled in loop through form elements var myForm = document.forms["myForm"]; var emailbody = ""; var form = document.getElementById('myForm'); for(var i=0; i < form.elements.length; i++){ if(form.elements[i].value === '' && form.elements[i].hasAttribute('required')){ alert('Fields marked with * are Required.'); return false; } }

Code

html
css
js
scripts

Download & Run

Download File Run Demo Re-load Preview

Preview

xaeGZ