jquery - Check whether form is submitted or not -


in webpage form there submit button (id = search) , predict button(id = predict). if user doesn't submit form, clicks predict button must alert form not submitted. how check whether form submitted or not in jquery.

$(document).ready(function(){         $('#predict').click(function(){          if($('#search').submit()) {                          window.open("ouput.php");            }        else {           alert("please click search or upload button first \n\              , click predict ");           }     }); }); 

but alert box not appearing , if form not submitted ouput.php page opening.

i don't know if understand correctly question , if you
in page have form, when submit form script add class ok predict button.
when click on predict button script chcks presence of ok class
if scripts not find class alert message show up

<!doctype html> <html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){  $('#a').submit(function(){     $('#predict').addclass('ok')      })   $('#predict').click(function(){     var clas=$(this).attr('class')       if(clas!=='ok'){         alert('you must submit form')     }   }) }) </script>  </head> <body> <form id="a" action="#">     <input type="text" value="">     <input type="submit" value="summit" id="search">     <input type="button" value="predict" id="predict"> </form> </body> </html> 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -