Jump to content

Disable "enter' in a form to stop it submitting form

Recommended Posts

On 3/26/2021 at 11:38 PM, amiem said:

Hi there!

Im wondering if anyone could help me!!?

I am trying to find a way to stop the form submitting when you press enter / return when filling out the text boxes?

Any help much appreciated!

Thanks!

Simple jquery can help

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>
$(document).ready(function() {
	$('.sqs-block-form').on('keypress keydown keyup', function(e){
       if(e.keyCode == 13) { e.preventDefault(); }
    });
});
</script>

 

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 9 months later...

@tuanphan @bangank36 

I'm hoping you can further help me with the same issue. In my Squarespace 7.1 website form, I want the enter / return button to simply act as a tab keystroke to allow my audience to put in a list of names into a text field without prematurely submitting the form. I used the code you suggested above but it resulted in fully disabling the enter/return button. Do you have any suggestions on how to modify the code? Thanks!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.