I am doing an XML form validation and form validation with validate() method. The XML validation is to check if they filled out the required fields, are the fields in proper length and etc. while the validate method performs database look up if the entered value exist in the database. if it does exist it will add a field error.
Now my problem. when I submit the form and I did not fill out the requiredstrings it will add an error to page, but when I enter a valid value it still prompts the same error(and at the same time it does not call the validate method).
this is my form.
Register for a prize by completing this form.
UserName
targets="result"
value="AJAX Submit"
indicator="indicator"
button="true"
/>
Register-validation.xml
/p>
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
User name is required.
And my validate from the RegisterAction class.
public void validate(){
if(userBean != null && userBean.getUsername().equals("foo")){
this.addFieldError("userBean.username", "That Username already exist");
}
}
The Scenario what I am doing.
I will submit the form without filling up the required string, and then I will enter a valid value, after the submitting the form the same error still exist.