Hey basically just having a little trouble with the following, submitting a message from a textarea, and on clicking of the submit button the following runs… I need the button to be disabled or another way which stops the user from clicking the button several times and submitting the message over and over again. I think I know where I am going wrong below that it is disabling the button before it is submitting?. At the moment with the disabling code in, it disables the button but does not submit the message, if I remove it, it submits fine.
$("#leaguesubmit").click(function(){
if($('#messageinput').val().length > 300 || $('#messageinput').val().length == 0 || $('#messageinput').val() == "Please enter your league message here..." ){
return false;
}else{
$("#leaguesubmit").attr("disabled","disabled");
return true;
}
});
You’re right; once ‘disabled’ is set, the form won’t submit. Try setting some other attribute when the form is submitted, and checking for it if the button is clicked again as part of the validation you’re already doing: