Saturday, February 9, 2013

Javascript validation in struts when using < sx : submit > to submit a form

Key here is to use the 'beforeNotifyTopics' attribute of the . In the value of this
attribute you have to specify the name of the javascript method that sould be called.

For example,

< sx : submit value="submit" targets="mainContentDiv" showloadingtext="false"
indicator="loadingImage"
beforenotifytopics="/beforeQuestionnaireSubmit"
id="submitQuestionnaireButton" / >


Then you have to add the javascript method that should do the validation in the following way

dojo.event.topic.subscribe("/beforeQuestionnaireSubmit", function(event, widget) {
var btn = dojo.byId("submitQuestionnaireButton");
btn.disabled = true;

var validationSuccess = true;
for(var i = 1; i < isanswered =" false;" j =" 0;" isanswered =" true" isanswered =" true" classname = "normal" classname = "normal" validationsuccess =" false;" classname = "highlight" classname = "highlight" validationsuccess ="=" disabled =" false;" cancel =" true;" name="'global.enquete.allanswer'/">");
}
});

No comments:

Post a Comment