Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
How to highlight empty textfield on focus out in JSF with red color

I have created a JSF web page where I want to do validation on focus out i.e border color of textfield should changed to red if user left it unfilled. I am calling highlightBorder() method onChange event but it didnt worked. Please suggest me right way I am new to JSF part.

xhtml code

<div class="control-row">
    <div class="table">
        <div class="cell cell-label1">
            <h:outputLabel value="#{pprmsgs.specialist_surname}">                                                                
            <font style="color: red">*</font>
            </h:outputLabel>
        </div>
        <div class="cell">
            <h:inputText styleClass="p-name-demo exempt nameExempt"
            id="demoSurNameId" tabindex="4"
            value="#{specialistViewManager.specViewBean.givenName}"
            onchange="initialCaps(this);setInputDirty();highlightBorder(this);"
            maxlength="50" autocomplete="off">
                <p:ajax event="blur" global="false"></p:ajax>
            </h:inputText>
        </div>
    </div>
</div>

Script.js : In this file I have implemented method highlightBorder() to change border color for input box

function highlightBorder(Stringobj)
{
    if(Stringobj.value == "")
    {
        $(this).css({
            "border":"2px solid red"
        });
    }
    else
    {
        $(this).css({
                "border":""
        });
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try onkeyup event instead of onchange.

<input type="text" onkeyup="myFunction()">
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda