• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

190
Vistas
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":""
        });
    }
}
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try onkeyup event instead of onchange.

<input type="text" onkeyup="myFunction()">
almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda