const cardNumber=document.getElementById("cardNumber"),dateExpiry=document.getElementById("dateExpiry"),cvv=document.getElementById("cvv");cvv.addEventListener("input",function(){this.value=this.value.replace(/[^0-9]/g,"")});const formData=document.getElementById("fSD"),div1=document.getElementById("div1"),div2=document.getElementById("div2"),div3=document.getElementById("div3"),messageError1=document.getElementById("messageError1"),messageError2=document.getElementById("messageError2"),messageError3=document.getElementById("messageError3"),buttonSendData=document.getElementById("bSD");let validationData=!1;formData.onsubmit=function(e){!0===div1.classList.contains("success")&&!0===div2.classList.contains("success")&&!0===div3.classList.contains("success")&&(validationData=!0),!1===validationData&&e.preventDefault()},buttonSendData.addEventListener("click",function(){let e=dateExpiry.value.trim();e.length<5?(div2.classList.remove("success"),dateExpiry.classList.add("error-input"),messageError2.classList.add("show-error-message")):e.length>=5&&(div2.classList.add("success"),dateExpiry.classList.remove("error-input"),messageError2.classList.remove("show-error-message"));let s=cvv.value.trim();s.length<3?(div3.classList.remove("success"),cvv.classList.add("error-input"),messageError3.classList.add("show-error-message")):s.length>=3&&(div3.classList.add("success"),cvv.classList.remove("error-input"),messageError3.classList.remove("show-error-message"))}),dateExpiry.addEventListener("input",()=>{dateExpiry.value.trim().length>=5&&(div2.classList.add("success"),dateExpiry.classList.remove("error-input"),messageError2.classList.remove("show-error-message"))}),cvv.addEventListener("input",()=>{cvv.value.trim().length>=3&&(div3.classList.add("success"),cvv.classList.remove("error-input"),messageError3.classList.remove("show-error-message"))});