• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross Post...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand but i still did not get the answer ..
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What part don't you understand?
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic