Notifications
Clear all

wpForo 1.x.x [Solved] What JQuery can make Tags a required field in the Add-Topic form, when ID keeps changing?

2 Posts
2 Users
1 Likes
988 Views
Posts: 124
Topic starter
(@mplusplus)
Reputable Member
Joined: 4 years ago

Hi there

I see that in the Add Topic form, the ID of the Tags input element keeps changing. So, what JQuery code can make it a required field, please?

I tried this but it did not work.

$.wpf_tags.attr("required", true);

Thanks.

1 Reply
Alvina
Posts: 1869
Moderator
(@alvina)
Member
Joined: 5 years ago

Hi @mplusplus,

Please try the following JS code:

function wpfcf_make_tags_required(){
jQuery('form[data-textareaid] input[id^=wpf_tags_]').prop('required', true);
}
jQuery(document).ready(wpfcf_make_tags_required);
document.addEventListener('wpforo_topic_portable_form', wpfcf_make_tags_required);

The code should be added in the current active theme JS  files.