I have a textarea and I need to stop the line breaks from happening when enter is pressed. Why doesn't return false work?
[syntax=javascript]
if (is_key(event, 13) && (with_field.value.length > 1)){
var search_list_ele_array = new Array();
var search_list_ele_array = document.getElementById('with_auto').getElementsByTagName('li');
for (j=0; j<search_list_ele_array.length; j++) {
if ((search_list_ele_array[j].className == 'user list_hover') || (search_list_ele_array[j].className == 'comp list_hover') || (search_list_ele_array[j].className == 'blog list_hover')){
var link = search_list_ele_array[j].getElementsByTagName('a');
user_add(link[0], search);
}
}
return false;
}
[/syntax]
Stop Enters
Re: Stop Enters
if you don't want multilines why are you using a text area?
i haven't tried achieving this, but try using substr. textbox value = substr(0,textbox.value - 1)
just a quick thought off the top of my head.
i haven't tried achieving this, but try using substr. textbox value = substr(0,textbox.value - 1)
just a quick thought off the top of my head.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Stop Enters
Torniquet wrote:if you don't want multilines why are you using a text area?
i haven't tried achieving this, but try using substr. textbox value = substr(0,textbox.value - 1)
just a quick thought off the top of my head.
Your quick thought might be good in theory but it is not correct. If I wrote "Hi am really cool [enter]", then that would erase everything I just wrote which is not what I want to do. I want to disable enters, NOT trim them. P.s. I just need a text area... too long to describe.
Re: Stop Enters
I think you would have use that method, the code should have been
[syntax=javascript]textbox.value = textbox.value.substr(0, textbox.value.length - 1);[/syntax]
[syntax=javascript]textbox.value = textbox.value.substr(0, textbox.value.length - 1);[/syntax]
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Stop Enters
jacek wrote:I think you would have use that method, the code should have been
[syntax=javascript]textbox.value = textbox.value.substr(0, textbox.value.length - 1);[/syntax]
Hmm that actually still didn't work for me.
I need to you use...
[syntax=javascript]
with_field.onkeypress = function(event){
if (is_key(event, 13) === true){
return false;
}
}[/syntax]
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: Stop Enters
jacek wrote:so what error are you getting now ?
Whoops I meant that the thread above was what I needed to use. It works now.