Setting an attribute in Jquery not working
Posted
by Probocop
on Stack Overflow
See other posts from Stack Overflow
or by Probocop
Published on 2010-04-28T15:29:49Z
Indexed on
2010/04/28
15:33 UTC
Read the original article
Hit count: 125
jQuery
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?
© Stack Overflow or respective owner