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

how should i remove the error message for the required text field once i move to another text field

 
Jyothi Sree
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a jsp form in a struts2 application , which has few strtus2 tag text fields and a submit button .
When i hit the submit button with out enterning the values in the textfields i get a error messages for the required fields saying that the " value is required "

validation is not a problem .. but once i enter the value in the textbox and move to the next textbox ,first fields error msg should disappear , i know this has to be done using ajax but how should i do that ?

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please TellTheDetails.

Are you using Ajax validation? If you're not, then dynamically modifying the DOM to remove static error messages has nothing to do with Ajax. If you are, the simplest solution might just be to re-submit the form for validation.

Are you using client-side validation? If you're not, then this is more trouble than it's worth. If you are, then perhaps just setting up some onblur handlers and re-calling the validation would be the easiest way.
 
Jyothi Sree
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am validating my Form Fields using the <actionclassname>-validation.xml which calls by itself when i submit the form .I dont think this is an ajax validation.

This is my Form

<body>
<s:fielderror />
<s:actionmessage/>
<hr>

<s:form action="contactus.action" method="post" name="ContactUs Form" >

<s:textfield id="fn" name="cust.fname" key="fname" size="25" maxlength="20" required="true" />
<s:textfield name="cust.lname" key="lname" size="25" maxlength="20" required="true" />
<s:textfield name="cust.title" key="title" size="25" maxlength="20" required="true"/>
<s:textfield name="cust.company" key="company" size="25" maxlength="50" required="true" />

<s:submit value="submit" align="center" method="addContact" />
</s:form>
</body>


With ContactUsAction-validation.xml as validation

Can You be more specific with the answer .

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're not using Ajax or client-side validation in the first place then I don't really think this is a reasonable requirement, because the field hasn't been re-validated yet. That aside, use an onblur to clear the associated error message; I think it's in a span. I'm not sure what the current state of the generated HTML is; you might have to resort to some minor DOM traversal to find it unless you extend a theme to produce more semantic markup.
 
Ankit Garg
Sheriff
Posts: 9520
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cross Post...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jyothi: Please BeForthrightWhenCrossPostingToOtherSites; if in had known the question was already answered I wouldn't have spent as much time answering it again.
 
Jyothi Sree
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand but i still did not get the answer ..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What part don't you understand?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic