hi!
i am validating my form.the form has two different submit button like "SAVE" and "UPDATE" button.but i don't know how to different validatation while i clicking save button and update button.how to differentiate the function calling...?
thank you,
kaleeswaran
You could change the action with javascript to point to different validating actions depending on what you click
struts-config:
<form path=/ValidateUpdate" validate="true" type="myClass" name="myForm" scope="request"/>
<form path=/ValidateSave" validate="true" type="myClass" name="myForm" scope="request"/>
jsp:
<html:form onsubmit="return getAction(this)" method="post" action="/ValidateSave">
<html:hidden name="myForm" property="submitValue"/>
<html:button onclick="setSubmitValue('save')" name="myForm" property="save" value="save"/>
<html:button onclick="setSubmitValue('update')" name="myForm" property="update" value="update"/>
</html:form>
js
function getAction(f){
var submitVal = document.getElementById("submitValue").value;
if(submitVal=='update')
f.action.value = "/ValidateUpdate.do";
else
f.action.value = "/ValidateSave.do";
return true;
}
function setSubmitValue(val){
document.getElementById("submitValue").value = val;
}