S
Simon
Hello, i have a problem..
I have a textarea wich sets hard returns (wrap=hard) at the end of a line,
further more a javascript counts the amount of lines. (More than four lines
will cause an alert)
It validates on onkeyup
Everything works fine, if I type something and use the return on keyboard,
type some more on the next line..press return..and so on till i've reached
the 5 line an alertbox will tell me that the maximum amount of lines is
reached.
The problem is when i don't use the return on my keyboard the script doesn't
recognize the end of the line!
So i can type four lines without using return but let the tekstarea do it's
work automatically. As you may know, a tekstarea automatically breaks lines
during typing and i thougt that with the parameter i use: WRAP=HARD the
javascript would recognize the hard returns.
I'll show you the script:
<SCRIPT LANGUAGE="JavaScript">
function validate() {
tempwaarde=document.selectForm.NOTES.value;split(tempwaarde,'\n');
if (splitIndex > 4) {
alert('Maximum amount of lines reached')
tempTxt=document.selectForm.NOTES.value;document.selectForm.NOTES.value=temp
Txt.substring(0,(tempTxt.length-2));
return false;
}
return true;
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
function split(string,text) {
splitArray = string.split(text);
splitIndex = splitArray.length;
}
</SCRIPT>
<form method="post" name="selectForm"><TR><td valign="top"><font
size=2><b></b></font></td><td><textarea rows="18" cols="125" name="NOTES"
style="font-family:times new roman;margin-left: 10;" wrap="hard"
onkeydown="return validate();"></textarea>
Can anybody help me with this? There must be a way. I don't want to validate
the amount off characters, just the amount of lines.
Thank you
I have a textarea wich sets hard returns (wrap=hard) at the end of a line,
further more a javascript counts the amount of lines. (More than four lines
will cause an alert)
It validates on onkeyup
Everything works fine, if I type something and use the return on keyboard,
type some more on the next line..press return..and so on till i've reached
the 5 line an alertbox will tell me that the maximum amount of lines is
reached.
The problem is when i don't use the return on my keyboard the script doesn't
recognize the end of the line!
So i can type four lines without using return but let the tekstarea do it's
work automatically. As you may know, a tekstarea automatically breaks lines
during typing and i thougt that with the parameter i use: WRAP=HARD the
javascript would recognize the hard returns.
I'll show you the script:
<SCRIPT LANGUAGE="JavaScript">
function validate() {
tempwaarde=document.selectForm.NOTES.value;split(tempwaarde,'\n');
if (splitIndex > 4) {
alert('Maximum amount of lines reached')
tempTxt=document.selectForm.NOTES.value;document.selectForm.NOTES.value=temp
Txt.substring(0,(tempTxt.length-2));
return false;
}
return true;
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">
function split(string,text) {
splitArray = string.split(text);
splitIndex = splitArray.length;
}
</SCRIPT>
<form method="post" name="selectForm"><TR><td valign="top"><font
size=2><b></b></font></td><td><textarea rows="18" cols="125" name="NOTES"
style="font-family:times new roman;margin-left: 10;" wrap="hard"
onkeydown="return validate();"></textarea>
Can anybody help me with this? There must be a way. I don't want to validate
the amount off characters, just the amount of lines.
Thank you