how to stop a form submitting when you press enter php

how to stop a form submitting when you press enter php

how to stop a form submitting when you press enter php

You've created a lovely form but whenever someone presses enter your form submits when you don't want it to you just want it to move to the next field or even stay on that field.

I searched for an answer to this on line but didn't come up with one. All php checks ie isset form submit or submit =1 etc etc all never worked until i added another submit button.

Then it became simple case of if ($_POST['submit']=='SUBMIT') {

Your code goes here

}

If you only want one button then you need to hide the other button. Alas using visibility doesn't work as this ignores that there is another button there and creates the same problem.

So i created a button that had the same background and border color as my page background. and width=1 this will make a small button that won't be seen and solves the problem of hitting the enter button.

 


SELL SELL SELL