Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
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 answers
Answer question

0

Try onkeyup event instead of onchange.

<input type="text" onkeyup="myFunction()">
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!