Scott Beckman
Scott Beckman

Reputation: 11

HTML Form Submission Issues

I'm working on a basic landing page with a one-field form. It's my first foray into forms so forgive me if this is basic or obvious.

Here's the code for the form:

<form action="#" method="post" onsubmit="alert('Thank you - we'll send an invite soon.')">
    <p><label for="email">ENTER YOUR EMAIL: </label><input type="email" id="email" name="email"/>
    <input name="Submit" type="button" value="Submit"/></p>
</form>

As you can see, it's pretty basic. However, the submit button doesn't work; you have to press enter to submit the form. On top of that, I can't get the onsubmit alert to work either. I've tried a thousand different configurations with minimal success, and I'm at the end of my rope.

Upvotes: 0

Views: 61

Answers (4)

imran
imran

Reputation: 187

Since You want to submit a form you mast use input type = submit . For example:

<input type="submit" value="Submit"/>

You can also use

<button type="submit"> Submit </button>

Upvotes: -2

Geo Perez
Geo Perez

Reputation: 256

Change the Button type to submit and also fix your Javascript, you have an extra apostrophe:

<form action="#" method="post" onsubmit="alert('Thank you - we will send an invite soon.');">
    <p><label for="email">ENTER YOUR EMAIL: </label><input type="email" id="email" name="email"/>
    <input name="Submit" type="submit" value="Submit"/></p>
</form>

Upvotes: 3

garryp
garryp

Reputation: 5766

Change the button type to submit

<input name="Submit" type="submit" value="Submit"/>

Upvotes: 3

Quentin
Quentin

Reputation: 943561

type="button" isn't a submit button. It's a "does nothing" button that you can hang JavaScript from.

You are looking for type="submit".

Upvotes: 2

Related Questions