Skip to main content
added 4 characters in body
Source Link
TylerH
  • 21.3k
  • 84
  • 84
  • 121
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(''); }   }) 

})

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(''); } 

})

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(''); }   }) 
Source Link
Ajay
  • 105
  • 1
  • 5

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(''); } 

})