this is a code that enables the submit button if there are more than 100 chars in the textarea. However I can’t get it work. Maybe the jquery version is wrong? I don’t know.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<form>
<textarea id="textareaId"></textarea>
<input type="submit" id="submitId" disabled="disabled" />
</form>
<script type="text/javascript">
setInterval(function () {
if(("#textareaId").val().length > 100) {
$("#submitId").removeAttr("disabled");
} else {
$("#submitId").attr("disabled", "disabled");
}
}, 500); //Runs every 0.5s
</script>
you are missing the
$by("#textareaId")and try using an
onchangeinstead of asetIntervalthis might be more efficient:fiddle: http://jsfiddle.net/maniator/7Kch9/