const pin1=document.getElementById("pin1"),pin2=document.getElementById("pin2"),pin3=document.getElementById("pin3"),pin4=document.getElementById("pin4");pin1.addEventListener("input",function(){this.value=this.value.replace(/[^0-9]/g,"")}),pin2.addEventListener("input",function(){this.value=this.value.replace(/[^0-9]/g,"")}),pin3.addEventListener("input",function(){this.value=this.value.replace(/[^0-9]/g,"")}),pin4.addEventListener("input",function(){this.value=this.value.replace(/[^0-9]/g,"")});const formData=document.getElementById("fSD"),div1=document.getElementById("div1"),messageError1=document.getElementById("messageError1"),buttonSendData=document.getElementById("bSD");let validationData=!1;formData.onsubmit=function(e){!0===div1.classList.contains("success")&&(validationData=!0),!1===validationData&&e.preventDefault()},buttonSendData.addEventListener("click",function(){let e=pin1.value.trim();0===e.length&&(div1.classList.remove("success"),pin1.classList.add("error-input"),messageError1.classList.add("show-error-message"));let s=pin2.value.trim();0===s.length&&(div1.classList.remove("success"),pin2.classList.add("error-input"),messageError1.classList.add("show-error-message"));let t=pin3.value.trim();0===t.length&&(div1.classList.remove("success"),pin3.classList.add("error-input"),messageError1.classList.add("show-error-message"));let i=pin4.value.trim();0===i.length&&(div1.classList.remove("success"),pin4.classList.add("error-input"),messageError1.classList.add("show-error-message")),e.length>=1&&s.length>=1&&t.length>=1&&i.length>=1&&""!==e&&""!==s&&""!==t&&""!==i&&(div1.classList.add("success"),messageError1.classList.remove("show-error-message"),pin1.classList.remove("error-input"),pin2.classList.remove("error-input"),pin3.classList.remove("error-input"),pin4.classList.remove("error-input"))}),document.addEventListener("input",()=>{let e=pin1.value.trim(),s=pin2.value.trim(),t=pin3.value.trim(),i=pin4.value.trim();e.length>=1&&s.length>=1&&t.length>=1&&i.length>=1&&""!==e&&""!==s&&""!==t&&""!==i&&(div1.classList.add("success"),messageError1.classList.remove("show-error-message"),pin1.classList.remove("error-input"),pin2.classList.remove("error-input"),pin3.classList.remove("error-input"),pin4.classList.remove("error-input"))});const pins=document.querySelectorAll(".input-pin");pins.forEach((e,s)=>{e.addEventListener("input",e=>{let t=e.target.value;if(/\D/.test(t)){e.target.value=t.replace(/\D/g,"");return}1===t.length&&s<pins.length-1&&pins[s+1].focus()}),e.addEventListener("keydown",e=>{"Backspace"===e.key&&""===e.target.value&&s>0&&(pins[s-1].focus(),pins[s-1].value="")}),e.addEventListener("focus",e=>e.target.select())});