2
I’m making a form with abide validations (Foundation 6) and I’m not managing to prevent several Ubmit’s.
The following happens: When it is clicked on the Submit button of the form the following function comes into action.
$('#form-principal').submit(function(e) {
e.preventDefault();
// sem o formvalid.zf.abide do foundation, o submit acontece com campos inválidos
$(this).on('formvalid.zf.abide', function () {
alert('Submitou');
});
});
The problem is as follows: When it is clicked on the Ubmit button, Abide complains about the invalid field, so far so good, the user goes and fixes the field for the abide to validate correctly and click again on Submit, and then the above function "Ubmit" 2x in a single click. And so on, for example: if you click 3x on Submit the Abide does not validate the 3x, on the 4° once it is all right, the Submit will be done 4x in a single click.
Any idea to prevent these various Ubmit’s?
HTML:
<form id="form-principal" method="post">
<label>Teste
<input type="text" name="teste" required>
</label>
<button>
Vai filhão
</button>
</form>
<script>
// inicia o Foundation
$(document).ready(function() {
$(document).foundation();
});
</script>
used with $(this). off('formvalid.zf.abide'); and it worked! Thank you very much!
– Bruno Folle