March 26, 2012

Check if AJAX loaded form contain a submit button

Question by Merianos Nikos

Is there a way to check if the form that has been loaded with AJAX contain a submit button with jQuery ?

Answer by Darin Dimitrov

success: function(content) {
    $('#someplaceholder').html(content);
    var containsSubmitButton = $(':submit', content).length > 0;
}

Answer by Starx

You can do it as this

$("#div").load("yourpage", function() {
    if($("#div").find(":submit").length > 0) {
          console.log("yes");
    }
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!