var counter = 1; var limit = 100; function addDateInput(divName){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); } else { var newdiv = document.createElement('div'); newdiv.innerHTML = " to " document.getElementById(divName).appendChild(newdiv); counter++; } dojo.parser.parse(); }