Get value from ajax-loaded form before submitting
- by ldvldv
Hi,
I have an app that loads an ajax form when a button is clicked. I then want to check a value in that ajax loaded form called "comment_content" so that I don't send an ajax request if the comment_content is empty. I can capture the form submission using the live method, however, I can't capture the form element because it needs an element.
I was looking at livequery but was wondering if there is a more efficient way by using live or if that I shouldn't even bother? Your help is very much appreciated.
$("#comment_submit").live('click', function(){
var comment = $("#comment_content").html();
if(comment == ""){
$("#notice").html("").stop(true, true);
$("#notice").append("<p>Are you going to write something in that comment?</p>");
$('#notice').slideDown().delay(2000).slideUp();
return false;
}
return true;
});