MyBB Community Forums

Full Version: Text Area Conditional
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm setting up an xthreads text area to display an "Admin Notice" and I'd like it to only display IF the text area contains some text. I'm not sure how to do this and was curious if someone could help me with it.
You can hide the textarea using jquery (or even it is possible by simple template edit : not a clean way though) when the textarea is empty.
(2019-02-20, 12:16 PM)effone Wrote: [ -> ]You can hide the textarea using jquery (or even it is possible by simple template edit : not a clean way though) when the textarea is empty.

Ah perfect. I was able to ad a div id and telll jquery to show it if it contained any text

I basically set up an "Admin Only" input field so that an admin can show an alert on a thread if they need to get the attention of the user.

<script>
$("#admin-alerts").each(function(i, val) {
    if ($(this).text().trim() === "") {
        $(this).hide();
    }
});
</script>

[attachment=41561]
Nice. In case of without jquery set classname as hide{no_admin} and set the chass hide as hidden through css. So if {no_admin} has a value the class name changes and the element eventually shows up.