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>

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();
    }
 });

Thanks for your reply,but it's not displaying correct result.

Then what is it displaying? :)

Thanks,

It works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.