Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: client side repeated validation error messages

 
thirumal raps
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts2 addErrors in javascript to show action errors in my jsp

my javascript sample code:

for (i = 0; i < chk.length; i++)
{
if(chk[i].checked == true)
{
unitQty = document.forms[0].elements["qty"][i].value;
if(qty == ''){
field = document.forms[0].elements["qty"][i];
addError(field, "Quantity is required");
errors = true;
}

when I click on submit it shows the error message "Quantity is required, but when I click it again it shows the new error message without clearing the last one

even through i am clearing error messages in my javascript code with
form = document.getElementById("User");
clearErrorMessages(form);
clearErrorLabels(form);

can anybody help me please

thanks
Thirumal

 
thirumal raps
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found the problem

i have added this code in validation.js so that i can clear the multiple error messages in table rows

function clearErrorMessages(form) {

var rows = form.getElementsByTagName("tr");
if (rows == null){
return;
}

for(var i = 0; i < rows.length; i++) {
var r1 = rows[i];
if (r1.getAttribute("errorFor")) {
rows[i].parentNode.removeChild(rows[i]);
}
}
}

thanks
thirumal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic