Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:07:52+00:00 2026-05-26T11:07:52+00:00

In the output of the following Java Server Faces (JSF) markup, the ‘Description’ field

  • 0

In the output of the following Java Server Faces (JSF) markup, the ‘Description’ field is initially not rendered, and is rendered (by Ajax) when you enter input in the ‘Name’ field.

When you type (more than 5 characters) in the Description field, the field should comes as red according to the jQuery code. But it is not happening.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>title</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript">
            jQuery (document).ready(function(){

        jQuery("#description").keypress(function(){

          if (jQuery(this).val().length >5){

              jQuery(this).css("background-color", "red");
          }else{
            jQuery(this).css("background-color", "white");   
          }
            console.log(jQuery(this).val().length); 
             })   
    })
</script>
    </h:head>
    <h:body>

           <h:form prependId="false">
            Name: <h:inputText id="name" value="#{viewScope.name}">
                <f:ajax execute="@this" render="@form"/>
            </h:inputText>
            <br/>
            <h:outputText id="descriptionLabel" value="Description:" rendered="#{empty viewScope.name ? false : true}"/>
            <h:inputText id="description" value="#{viewScope.description}" rendered="#{empty viewScope.name ? false : true}"/>
       <!-- <h:outputText id="descriptionLabel" value="Description:" />
            <h:inputText id="description" value="#{viewScope.description}" />-->
        </h:form>

            </h:body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:07:52+00:00Added an answer on May 26, 2026 at 11:07 am

    Just replace the keypress event binding to live.

    jQuery("#description").live('keypress', function() { ... });
    

    The live function will attach a handler to the event for all elements which match the current selector, now and in the future and in your case the description element is not yet presented in the DOM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following output from a Tomcat server under Eclipse: INFO: Initializing Coyote HTTP/1.1
I have Java classes with the following structure (the class names do not imply
The following output appears after running some rake tasks: Loaded suite /usr/bin/rake Started Finished
I want to output the following string in PHP: ä ö ü ß €
I have the following output (via link) which displays the var_dump of some XML
I'm trying to output the following html using an html helper in asp.net mvc
In my current repo I have the following output: $ git branch -a *
Can someone tell me how I can make the following output? I have a
What does it mean when it gives a backtrace with the following output? #0
I'm trying to create an algorithm in C# which produces the following output strings:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.