2

I have two submit button in form, one button for validate and form submit form reload, Another one for submit the form with out validate in ajax method, How to do this.

HTML Code:

<form action="" id="form-product" method="post" name="product" enctype="multipart/form-data">
 <input type="text" name="title"id="title">
 <input type="submit" name="save">  
 <input type="submit" name="enter">
</form>


$(function() {
$("form[name='product']").validate({
rules: {
 title: {
    required: true,

    },

},
messages: {     
title: {
  required: "Please enter your Emailid.",

}, 
},

    submitHandler: function(form) {
      form.submit();
    }
  });
});
Sagar V
  • 12,158
  • 7
  • 41
  • 68

2 Answers2

1

Actually you can do it a numerous way.I will show you one possible way,

<form action="" id="form-product" method="post" name="product" enctype="multipart/form-data">
 <input type="text" name="title"id="title">
 <input type="button" name="save" value="validate" onclick="_validate()">  
 <input type="button" name="submit" onclick="_submit()" value="enter">
</form>

<script>
function _validate(){
    console.log("add your validation method here");
    // add your validation method here.
}
function _submit(){
   console.log("submit your form without validation");
   //just submit your form
}
</script>
Ataur Rahman Munna
  • 3,887
  • 1
  • 23
  • 34
0

HTML CODE:

     <input type='submit' id='btn1' value='Normal Submit'>
     <input type='button' id='btn2' value='New Window'>

JS CODE:

     document.getElementById('btn2').onclick = function() 
     {
     form.target = '_blank';
     form.submit();
     }

or simply try this:

   <input type='submit' name='self' value='This window' onclick='this.form.target="_self";' />

   <input type='submit' name='blank' value='New window' onclick='this.form.target="_blank";' />
S Dhanissh
  • 103
  • 1
  • 1
  • 15