AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

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

2 Posts
2 Users
1 Reactions
1,811 Views
Posts: 127
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@mplusplus)
Reputable Member
Joined: 6 years ago
[#14796]

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: 1857
Moderator
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@alvina)
Member
Joined: 7 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.


Share: