jQuery implements the method of judging when a form is submitted

  • 2020-05-05 10:53:26
  • OfStack

This article illustrates an example of how jQuery implements form submission. Share with you for your reference. The specific implementation method is as follows:

<input type="submit" id="myBtn" />

To:
<input type="button" id="myBtn" />

Use:

$("#myBtn").click(function(){
   ...// Determine validation
});

Form submission js:

function formSubmit(){
   if(flag=="1"){
     $("#form").submit();
   }else if(flag=="2"){
    $("#form").attr("action","deployResult.jsp");
    $("#form").attr("target","_blank");     $("#form").attr("method","GET");
    $("#form").attr("enctype","application/x-www-form-urlencoded");
    $("#form").attr("encoding","application/x-www-form-urlencoded");
    $("#form").submit();
  }
}

I hope this article is helpful for you to design web program based on jQuery.


Related articles: