0

Hi

I want to greet user when they type their name in the textbox.
e.g
WHEN THEY TYPED IN THEIR NAME A LITTLE POP UP, OR A LINE APPEARED IN AREA THAT SAID “Hi XXXXX, nice to meet you!”

Here is the sample code.

 <div class="form-group">
        <label class="col-xs-3 control-label">What is your full legal name?</label>
        <div class="col-xs-5">
            <input type="text" class="form-control" name="name" />
        </div>
    </div>
2
Contributors
4
Replies
26
Views
2 Years
Discussion Span
Last Post by baloch123
1

Change your HTML:

 <div class="form-group">
    <label class="col-xs-3 control-label">What is your full legal name?</label>
    <div class="col-xs-5">
        <p id="user_name_container">Hello <span id="user_name"></span>, nice to meet you!</p>
        <input type="text" class="form-control" name="name" />
    </div>
 </div>

Then your Javascript (using jQuery):

$('input[name=name]').keyup(function() {
    if ($(this).val()) {
        $('p#user_name_container').show();
        $('span#user_name').html($(this).val());
    }
    else {
        $('p#user_name_container').hide();
    }
 });

Edited by minitauros

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.