tags:

views:

29

answers:

3

Is it possible to type some text in form text field and at the same time see that text in DIV beside, without submitting the form first?

Something like:

<input type="text" name="text" id="text"/>
<div class="show_text_here"></div>
+1  A: 

It's not only possible, it's happening right here right now!

At its simplest, you'll just need to bind a handler to the proper event (.keyup() probably... check http://api.jquery.com/category/events) of that input and the only thing the handler needs to do is set the contents of the div to the value in the input.

There's a discussion on this same topic here: http://forum.jquery.com/topic/how-to-display-value-of-input-in-div-object-in-real-time

David
+1  A: 

How about something like this:

$('#text').keyup(function(){
    $('.show_text_here').html($(this).val());
}
dvcolgan
A: 

This code will do copy the value of the text box in real-time:

$('#text').keypress(function(){
  $('.show_text_here').html($(this).val());
});
Gert G
Won't using .keypress() clobber the input to the actual input field, though?
David
This code works fine.
Gert G