if form.process().accepted:
<all good>
elif form.errors:
focus_field = next(iter(form.errors.keys()))
return dict(........., focus_field=focus_field)
{{ if focus_field: }}
<script>
$(function() {
$("[name='{{=focus_field}}']").focus();
});
</script>
{{pass}}--How about in your controller,
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Gs5tr2lNIgQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/d189309d-a7e4-4fac-a007-02412532c1cco%40googlegroups.com.
if form.errors:
panel_to_show = ''
for field in form.errors:
if field in ['w4_filing_status']:
panel_to_show = 'collapseOne'
break
elif field in ['w4_two_jobs']:
panel_to_show = 'collapseTwo'
break
elif field in ['w4_qualifying_dependents', 'w4_other_dependents']:
panel_to_show = 'collapseThree'
break
else:
panel_to_show = 'collapseFour'
break
response.js = '$("#collapseOne").collapse("hide"); $("#%s").collapse("show");' % panel_to_showTo unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.