const username= document.querySelector('#username'); const submit=document.querySelector('#submit'); submit.addEventListener('click',()=>{ if(username.validity.typeMismatch){ username.setCustomValidity('Please enter User Name'); }else{ username.setCustomValidity(''); } if(pass.validity.typeMismatch){ pass.setCustomValidity('Please enter Password'); }else{ pass.setCustomValidity(''); } }) })