• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to focus on error field

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using validator framework and it is working fine. But is there any way to focus the cursor on the error field in struts. And how can we display only one error at a time.
Please help me!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vipin Sahu:
is there any way to focus the cursor on the error field in struts.


Yes, with a combination of Javascript and the <logic:messagesPresent>. Just specify an onload event in the <body> tag that references a JavaScript function. Then in that function, code something like this:

If fields A, B, and C all have errors, focus will be on FieldC since it's the last in the list. You therefore might want to put the conditions in the reverse order of how they appear on the screen. That way the top field on the screen that has an error will get the focus.

Originally posted by Vipin Sahu:
how can we display only one error at a time.


You do this using the property attribute. If you want a separate field that only shows errors for fieldA, specify the following:
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic