I am using jquery to display a dropdown if a boolean field is not selected.
Example below. The form does not pass validation as written.
How do I make the validation conditional?
thank you
fields.append(Field('f_all_user', type='boolean', label=T('Send to All
users'), default=True))
fields.append(Field('f_single_user', type='string', label=T('Send to One
user'),
requires=IS_IN_DB(db,'user.name',db.user._format,multiple=False
)))
form = SQLFORM.factory(*fields, table_name='send_email')
<script>
jQuery(document).ready(function(){
if(jQuery('#send_email_f_all_user').prop('checked') == false)
jQuery('#send_email_f_single_user__row').show();
else jQuery('#send_email_f_single_user__row').hide();
jQuery('#send_email_f_all_user').change(function(){
if(jQuery('#send_email_f_all_user').prop('checked') == false)
jQuery('#send_email_f_single_user__row').show();
else jQuery('#send_email_f_single_user__row').hide();});
});
</script>
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.