A Form Doesn't Submit

Submit button doesn't work

If you are not using any JavaScript for form validation then a simple layout for your form would look like this:

<form action="formHandler.php" method="post">    
<input name="fname" id="fname" type="text" value="example" />
<input type="submit" value="submit" />
</form>

You need to ensure you have the submit button within the form element and an appropriate action attribute on the form element is present.

For a more direct answer, provide the code you are working with.

You may find the following of use: http://www.w3.org/TR/html401/interact/forms.html

Why Form doesn't submit with javascript if an input field's name is submit

The problem is that the submit button has the name submit and this clash is overriding the form's submit() function.

If you remove the name="submit" attribute, this will work.

Here is some more information on conflicts:

http://jibbering.com/faq/names

http://paulsec.github.io/blog/2014/03/09/dealing-with-html-submits-conflict

form: doesn't send input - submit won't work (html/php)

Anyway, from reading the code I can see that $name, $kuerzel, and $website are never populated in your code. You set them to empty at the start just before the submit-block and then...nothing. You never attempt to read the data into them from the $_POST array. I'd be expecting to see $name = $_POST["name"]; etc. Have you studied any tutorials on how PHP works with forms? –

...solved it for me

HTML Form won't submit when text input is filled

I just didn't put in a valid email address so, since the input is type="email", it wouldn't let it submit.

After form validation, form doesn't submit

Edit: Please look at Stefano Dalpiaz answer first as he points out your mistakes.


All you have to do to check if a string is empty is this if ( !email ) (How do you check for an empty string in JavaScript?). You can also use .is(':checked') to determine if a checkbox is checked.

Here is a working fiddle: http://jsfiddle.net/p28am/1/

HTML:

<form class="form" action="">
<div class="wrapper-input email">
<input id="email" type="text" name="email" placeholder="youremailaddress@example.com" />
<button class="form-submit submit">Sign-Up</button>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="wrapper-input">
<input type="checkbox" id="terms" name="terms" value="Agree"> <span>Click to agree</span>

</div>
</form>
<div class="modal">
<div class="modal-title">
<h4 class="success">Submission Successful!</h4>

<h4 class="error">Submission Error!</h4>

<img class="close" src="img/close-x.png" alt="close" />
</div>
<div class="modal-content">
<p class="success">Sucess</p>
<p class="error">Error!</p>
</div>
</div>

JS:

$(document).ready(function () {
$(".submit").click(function () {
var email = $("#email").val();
var dataString = 'email=' + email;
var terms = $("input:checkbox#terms").is(':checked');

if (!email || !terms) {
$('.modal').show();
$('.success').hide();
$('.error').show();
} else {
$.ajax({
type: "/echo/json/",
url: "collect.php",
data: dataString,
success: function () {
$('.modal').show();
$('.success').show();
$('.error').hide();
}
});
}
return false;
});
});

$('.close').click(function(e){
e.preventDefault();
$('.modal').hide();
});

AJAX doesn't submit the form

Problem was HTML, not AJAX.

I just added a submit button and it worked as expected.



Related Topics



Leave a reply



Submit