1
I have a problem with my Javascript.
I am using a server code to do the numbering in a Textarea when the user gives Enter, however, if that TextArea
has the tag runat="server"
Javascript does not recognize the box and simply doesn’t work.
Javascript Code:
<script type="text/javascript">
$(document).ready(function () {
$("#objetivos_projeto").keyup(function (event) {
if (event.which != 13)
return;
var elm = $(this);
var lines = elm.val().split("\n");
for (var i = 0; i < lines.length; i++)
lines[i] = lines[i].replace(/(\d+\.\s|^)/, (i + 1) + ". ");
elm.val(lines.join("\n"));
});
});
</script>
Textarea code :
<textarea id="objetivos_projeto" runat="server" rows="5" cols="32">1. </textarea>
However, if you remove the tag runat="server"
the Javascript function already recognizes the TextArea
and does what he’s supposed to do.
Thank you, it was very helpful !
– Leandro Batista