Jump to content
OllieD

HTML form submit button

Recommended Posts

I have st up a form on my website for contacting my company. It has some required fields for name, email and message but when you click the submit button, an alert pops up to confirm the form being submitted even when the required fields haven't been filled out. How can I solve this?

 

This is the code for the form:

 

<form name="Contact" method="put" id="contact">
First Name: <input type="type" name="First" id="first" maxlength="20" required placeholder="First Name">
<br>
Last Name: <input type="type" name="Last" id="last" maxlength="25" required placeholder="Last Name">
<br>
Email: <input type="email" name="Email" id="email" maxlength="25" required placeholder="Email">
<br>
Message <input type="type" name="Message" id="message" maxlength="1000" required placeholder="Message">
<br>
<input type="reset">
<input type="submit" onClick="alert('Thank you for contacting us. We will process it as soon as possible')">
</form>

Share this post


Link to post
Share on other sites

You need Javascript to look at the fields when the form submit event fires and check that they have a proper value.

Share this post


Link to post
Share on other sites

Start by reading the Javascript tutorial.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...