I am trying to add Integer validation to the my Struts 2 application.
Here is what I have done
<validators>
<validator type="int">
<param name="fieldName">zipCode</param>
<message>Zip Code needs to be a valid number </message>
</validator>
</validators>
I have already set validate="true" in the <s:form> tag
This is successfully generating the java script code at my JSP. But when I see the generated code. The validation code for my field is
|
Quote:
|
<script type="text/javascript">
function validateForm_generateAction() {
form = document.getElementById("generateAction");
clearErrorMessages(form);
clearErrorLabels(form);
// field name: zipCode
// validator name: int
if (form.elements['zipCode']) {
field = form.elements['zipCode'];
var error = "Zip code should be a valid number";
if (field.value != null) {
if (false || false) {
addError(field, error);
errors = true;
}
}
}
return !errors;
}
</script>
|
Not sure why this code is coming
quote:if (false || false) {
Due to this it will not do validation for this field.
Any clue? Am I doing something wrong here? Please help.