0

I have a form with an inputText and a commandButton. When I click the buuton, it validates if the value of the inputText is a number. If not, a message is shown. I want, when the button is click, after checking that the value of the inputText is a number, to hide the form and at its position, to show a "ok" message. Here is my xhtml page form code:

<h:form id="formdata" > 
  <div id="col6-left" class="col-md-6">
    <div id="registration" style="padding:10px 40px; ">
      <h3 style="text-align: center">Enter your car registration</h3>
        <br/>
        <span  class="car-reg-widget">
           <input type="text" id="regnoinput" autofocus="true"/>
        </span>
        <div style="text-align: center; margin-top:30px;">
          <h3 style="text-align: center">Mileage</h3>
          <h:inputText style="width:30%; font-size:1.4em; text-align:center; " 
              id="mileage-text" 
              value="#{user.number}"  
              required="true" 
              label="The value" 
              requiredMessage="The mileage number is required"
              validatorMessage="must be a number."
              autocomplete="off">
           </h:inputText>
           <h:message id="fooMessage" for="mileage-text" style="color:red" />
           <br/><br/>
           <h:commandButton value="Get Valuation"
           action="result.xhtml"
           title="Get Valuation"
           class="btn btn-orange"></h:commandButton>

          <hr/>
          </div>
        </div>
      </div>
</h:form>

and here is my bean file code:

package control;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.ContextCallback;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;

@ManagedBean(name = "user")
@ViewScoped
public class UserBean implements Serializable {

    private static final long serialVersionUID = 1L;
    int number = 0;


    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }


}
  • learn about ajax.... – Kukeltje Aug 04 '16 at 18:35
  • I have not found the answer to my problem in other questions and this is the reason why I created a new question which exaclty explains my problem. I do not understand why it is duplicated! – Michail Touloupis Aug 05 '16 at 09:09
  • Simple... see [ask]. You did not state what you tried, what links you found and why they did not help. So we take a quick look at your post and almost immediately see that this is a case of what is in the duplicate. And I personally could not see why the duplicate is not valid. You question is very basic. – Kukeltje Aug 05 '16 at 09:13

0 Answers0