I have a simple "contact me" section on my website and I'm trying to figure out how to prevent the page on refreshing when a user enters in an invalid email. Reason why I want to prevent this is because when they enter in an invalid email the page refreshes and brings them to the top of the page. I have an error that displays what the user missed but they have to scroll back down to the contact section to see it. I'm not sure how to go about preventing the page from scrolling to the top after they submit. All I have right now is a simple php form validation. Any suggestions? would this be done with JavaScript? or can I add this to my existing php validation script? not sure where to start. thanks!
Side note i am using PHP for form validation.
FIXED! To prevent the page from going back to the top i removed "index.php" from my form action:
before
<form action="index.php" method="POST">
after
<form action="" method="POST">
now the page does not refresh and does not go to the top of the page.