javascript - How not to submit form, then submit it? -


i have form email input, 1 button overlapse it, when click on button, button sliding across input can input email. when click on button must submit form.

how make that?

<form action="http://databox.createsend.com/t/d/s/itkkyu/" method="post" class="subscribe-form" accept-charset="utf-8">  <input id="fieldemail" name="cm-itkkyu-itkkyu" class="input" type="email" placeholder="your company email">  <button class="get-notified" type="submit">get notified</button> </form> 

js:

(function () {     var count = 0;      $('.subscribe-form button').click(function () {         $('.subscribe-form').submit(function(e) {             e.preventdefault();             count += 1;         });      if (count == 1) {             console.log('oj');             $('.subscribe-form').submit(function() {              });      }     }); })(); 

use jquery.one() add 1 time event handler cancels submit, use jquery.submit() trigger submit event after whatever you're doing finished.

$('.subscribe-form').one('submit',function(e) {     e.preventdefault();     //     $(this).submit(); }); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -