arrow108
08-21-2006, 10:11 AM
I have a textarea that takes a max of 5ooo characters. If the user begins typing anywhere except for the absolute left of the textarea the form will not submit. i used a trim function in the if/else statement validating the form but i'm thinking that is incorrect because it isn't working as expected. here's the trim function -
function trim(s) {
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
}
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
}
return s;
}
here's the size validation contained w/in a lengthy form validation function too long to reprint here -
else if (trim(form.message.value) < "!" )
{
alert("Please enter your message.");
form.message.select();
form.message.focus();
return false;
}
So, when the user enters a message one line down (i.e., presses the hard return before typing) they get the alert box asking them to enter their message.
How can i fix this?
function trim(s) {
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
}
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
}
return s;
}
here's the size validation contained w/in a lengthy form validation function too long to reprint here -
else if (trim(form.message.value) < "!" )
{
alert("Please enter your message.");
form.message.select();
form.message.focus();
return false;
}
So, when the user enters a message one line down (i.e., presses the hard return before typing) they get the alert box asking them to enter their message.
How can i fix this?