Regex check for 5 digits but not consecutive 0

by Michel Plungjan

HTML

<input type="text" onkeyup="checkIt(this.value)" /> <span id="err">Please enter 5 digits not all 0</span>

JavaScript

function isValid5(str) {
  return str != "00000" && /^\d{5}$/.test(str);
}
function checkIt(str) {
  document.getElementById("err").style.display=isValid5(str)?"none":"";
}