Skip to content

Commit

Permalink
[E] Improvement to checkboxes #2357
Browse files Browse the repository at this point in the history
[E] Mark radio boxes required if not checked #2359
  • Loading branch information
lianglee committed Mar 6, 2024
1 parent bc17ada commit 085b092
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libraries/ossn.lib.users.php
Expand Up @@ -556,4 +556,4 @@ function ossn_get_admin_users() {
}
ossn_register_callback('ossn', 'init', 'ossn_users');
ossn_add_hook('load:settings', 'language', 'ossn_site_user_lang_code');
ossn_add_hook('user', 'default:fields','ossn_user_fields_set_nonrequired', 201);
ossn_add_hook('user', 'default:fields','ossn_user_fields_set_nonrequired', 1000);
Expand Up @@ -29,10 +29,25 @@ function ossn_user_signup_form(){
$('#ossn-home-signup input').filter(function(){
$(this).closest('span').removeClass('ossn-required');
if(this.type == 'radio' && !$(this).hasClass('ossn-field-not-required')){
if(!$("input[name='gender']:checked").val()){
$(this).closest('span').addClass('ossn-required');
failedValidate = true;
}
$radio_name = this.name;
//no checkbox is checked
if($("input[name='"+$radio_name+"']:checked").length == 0){
$(this).closest('.radio-block-container').addClass('ossn-required');
failedValidate = true;
} else {
$(this).closest('.radio-block-container').removeClass('ossn-required');
}
}

if(this.type == 'checkbox' && !$(this).hasClass('ossn-field-not-required')){
$checkbox_name = this.name;
//no checkbox is checked
if($("input[name='"+$checkbox_name+"']:checked").length == 0){
$(this).closest('.checkbox-block-container').addClass('ossn-required');
failedValidate = true;
} else {
$(this).closest('.checkbox-block-container').removeClass('ossn-required');
}
}
if(this.value == "" && !$(this).hasClass('ossn-field-not-required')){
$(this).addClass('ossn-red-borders');
Expand Down

0 comments on commit 085b092

Please sign in to comment.