| Author |
How to focus on error field
|
Vipin Sahu
Greenhorn
Joined: Mar 08, 2007
Posts: 6
|
|
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!
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
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:
|
Merrill
Consultant, Sima Solutions
|
 |
 |
|
|
subject: How to focus on error field
|
|
|