I'm trying to make a required field input - But when I put


in the apex:input component, Its like stuck the next JavaScript-dependent part and it's not working well until I fill it with a value.

Example :

<div class="col-md-3">
    <label class="control-label right-side" for="FirstName">First Name</label>
    <apex:input required="true" html-placeholder="Please Enter First Name"  styleClass="form-control"  value="{!firstName}"  id="firstnameId" />
<div class="col-md-3">
    <label class="control-label right-side" for="lastName">Last Name</label>
    <apex:input **required="true"** html-placeholder="Please Enter Last Name" styleClass="form-control"  value="{!lastName}"  id="lastnameId"/>

And then - the next action function is not working well :

    <apex:actionFunction name="searchAccount" action="{!searchAccounts}" reRender="table" />
    <apex:pageBlockTable styleClass="table hover" value="{!accounts}" var="c" id="table">

        <apex:column style="float:right;">
            <apex:commandLink value="{!c.name}" reRender="accountId,selectedProductListId,selectedProductItemListId" action="{!proceedToUpload}" oncomplete="closeTable();"> 
                <apex:param value="{!c.Id}" name="act" />
                <apex:param value="{!c.Name}" name="accountName" />




SearchAccounts is a function that looking for an account. But its not working. Only when I insert some text to the required inputs - Its working again.

Can anyone explain to me why this is happening and how can I fix it?

Or alternatively - another way to do it?


1 Answer 1


When there’s a required field in a VF page and we submit the form, sever does a validation to make sure those have values populated. If there are no values form submission is rejected.

You may want to consider partial submission of your form to the server. Try using <apex:actionRegion> here is a link

Try wrapping your action function in a action region so that it submits the partial form only.

  • my searchAccounts action inside the actionFunction is triggered on a keyUp - means that I making an autocomplete search which means I need to call the controller every letter that tapped inside this input field. I tried to wrap it inside the action region but without any success. when I make a field above this action function to be required, It just ruins the action function - It's like its stuck on the validation (without the necessity to press the submit button). When I put text inside the field that need to be required - the action function works great!
    – Salvation
    Commented Mar 10, 2019 at 11:47
  • Did you try setting ‘immediate = true’ on the action region?
    – Ranga
    Commented Mar 10, 2019 at 15:02
  • I did right now - Nothing :( The actionFunction is never called when one of the inputs fields have the required attribute.
    – Salvation
    Commented Mar 10, 2019 at 15:39
  • Hi, @Ranga I just figured out that I had a mistake somewhere in my code. Your solution is great. Its better late than never :) Thank you!
    – Salvation
    Commented Apr 11, 2019 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .