Here i have jsf code for input fileds that have an form validator.
<h:form id="myForm">
<script>
function resetform() {
document.getElementById("anomalies-list-form").reset();
}
</script>
<h:panelGrid>
<h:outputText value="Source IP"/>
<h:panelGroup>
<h:inputText id="SourceIP" size="13" value="#{dataListBean.sourceIp}" title="Enter first few letters for searching similar records" >
<f:validator validatorId="SQLInjectionValidator"/>
</h:inputText>
<h:message style="color:red" for="SourceIP"/>
</h:panelGroup>
<h:outputText value="IP"/>
<h:panelGroup>
<h:inputText id="IP" size="13" value="#{dataListBean.destIp}">
<f:validator validatorId="SQLInjectionValidator"/>
</h:inputText>
<h:message style="color:red" for="IP"/>
</h:panelGroup>
<h:outputText value=""/>
<h:panelGroup>
<h:commandButton id="show" value="Show" action="#{dataListBean.showSelectedType}"/>
<h:commandButton id="clear" value="Clear" onclick="resetform()">
</h:commandButton>
</h:panelGroup>
</h:panelGrid>
</h:form>
if i get a validation on any filed i want clear all filed with clear button but it is not working.