Page 1 of 1

Stop Enters

Posted: Mon Jun 27, 2011 5:43 pm
by unemployment
I have a textarea and I need to stop the line breaks from happening when enter is pressed. Why doesn't return false work?
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;
}

Re: Stop Enters

Posted: Mon Jun 27, 2011 6:35 pm
by Torniquet
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.

Re: Stop Enters

Posted: Mon Jun 27, 2011 7:08 pm
by unemployment
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

Posted: Tue Jun 28, 2011 10:00 am
by jacek
I think you would have use that method, the code should have been
textbox.value = textbox.value.substr(0, textbox.value.length - 1);

Re: Stop Enters

Posted: Tue Jun 28, 2011 1:05 pm
by unemployment
jacek wrote:I think you would have use that method, the code should have been
textbox.value = textbox.value.substr(0, textbox.value.length - 1);
Hmm that actually still didn't work for me.

I need to you use...
with_field.onkeypress = function(event){
	if (is_key(event, 13) === true){
		return false;
	}
}

Re: Stop Enters

Posted: Tue Jun 28, 2011 3:45 pm
by jacek
so what error are you getting now ? :?

Re: Stop Enters

Posted: Tue Jun 28, 2011 4:33 pm
by unemployment
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.