0

I have a form that I want to submit on page load. I also have a submit button that works just fine. But I would like to to able to also just go to an url and submit the form automagically and then the results can be refined by further changing the form.

I have the action defined in the form tag. The rest of my code looks like this and is placed within a $(window).on("load") block.

Everything is working fine, but validator.form() does nothing. If I .submit() the form with javascript the browser leaves the page and goes directly to the url in the action of the form.

var validator = $("#frm_sok").validate({
  rules: {
    searchinput: {
      required: true
    }
  },
  messages: {
    searchinput: {
      required: 'Du må neste søke etter noe. Noe som helst. Ett eller annet.'
    }
  },
  submitHandler: function(form) {
    preload_kamp();
    $(form).ajaxSubmit({
      success: function(data) {
        $("#sokcontent").html(data);
      }
    });
  }
});
validator.form();
johnohod
  • 494
  • 5
  • 19

0 Answers0