Home >
Technical & Creative Skills >
Programming, Servers & Scripts
Trigger CTA when pressing "Enter" button (4)
01-19-2017 06:52 PM
#1
jelz03 (Member)
Trigger CTA when pressing "Enter" button
Hey everyone,
I made a simple landing page with a text box where I ask visitors to enter their ZIP code followed by a CSS button as my call to action.
My problem is if someone enters their ZIP and press "Enter" on their keyboard it doesn't do anything.
I'd like my visitors to get sent to the next page (just as if they'd clicked the CTA button) when they press enter on their keyboard.
Here's the code:
<div align="center"><form><b>Enter Your Zip Code:</b><br>
<input type="text" name="ZIP"/>
</form></br>
<a class="btn btn-danger btn-lg btn-block" href="http://mylink.voluumtrk.com/click">Get Started Now!</a></div></br>
</div>
Any idea on how to do that?
01-19-2017 09:48 PM
#2
givizator (AMC Alumnus)
Replace <form> by
<form method="get" action="http://mylink.voluumtrk.com/click">
01-20-2017 12:14 AM
#3
happycoder (Member)
Yeah you can do givizator's thing, or you can also setup jQuery and set a handler for the enter key:
<script src="jquery-3.1.1.min.js"></script>
$(document).keypress(function(e) {
if(e.which == 13) {
window.location = YOUR_NEW_PAGE;
}
});
01-20-2017 09:35 AM
#4
jelz03 (Member)

Originally Posted by
givizator
Replace <form> by
<form method="get" action="http://mylink.voluumtrk.com/click">
Thank you! Works perfectly and is really simple.
Thanks happycoder, I'll keep this bit of code somewhere when I get better at coding.
Home >
Technical & Creative Skills >
Programming, Servers & Scripts