2

I'm trying to validate my form before the charge.js is triggered.

I've decided to drop submit button in favour of a standard button and then use valid() method to process submit, so this is what I have now:

<form id="charge-form">
<!-- some fields here !-->
<input id="submit" type="button" value="Subscribe">
</form>

<script>
  $("#charge-form").validate();
  $("#charge-form").charge();
  $("#submit").click(function() {
    if ($("#charge-form").valid()) {
        $("#charge-form").submit();
    }
  })
</script>

Validation works, and when testing the conditional statement with console.log it also works properly, but when actually used it gives $form.get(...).submit is not a function in the console in charge.js

enter image description here

Did anyone make jQuery Validate work with Charge?

2

Silly me, this has nothing to do with charge.js, one simply can't have a button with an id="submit" as weird things will happen - see this thread

<input type="button" id="otherThanSubmit"> 

this works fine

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.