ok so i solved it by replacing getElementById with getElementByName
but now another problem occurred,when i click on submitbutton it shows validation as invalid email but data gets submit
function checkEmail()
{
var email = document.getElementsByName('txtremail');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value))
{
alert('Please provide a valid email address');
email.focus;
return false;
}
else {
return true;
}
}
so ,now any solution how to stop data from submitting if email is wrong?