Setting an attribute in Jquery not working
- by Probocop
Hi, I have the following function which limits the amount of characters you can enter into a text area.
What's meant to happen is, if the text length is higher than the text limit, set an attribute of disabled="disabled" on the submit button, but it isn't getting set, my function code is as follows:
function limitChars(textid, limit, infodiv) {
var text = $('#'+textid).val();
var textlength = text.length;
if(textlength > limit) {
$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
$('input#submit').attr('disabled', 'disabled');
} else {
$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
}
}
Any ideas?