I have a problem with my JavaScript.
I am using a code that server 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 does not 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 runat="server"
tag the JavaScript function already recognizes TextArea
and does what it is supposed to do.