Thursday, May 14, 2009

How to do a 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'/">");
}
});

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This blog is now deprecated and please visit http://clubsking.blogspot.com to view this article and much more

    ReplyDelete