Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
464 views
in Plugins by
closed by

i know the js to count the length of field

but how to i can add onkeyup="countLength();" attribute to title field? like it already have a attribute onchange="qa_title_change(this.value);" done

how to to add a <p> tag after title field?

how to i get the value of Max length of title which is set in admin panel?

Q2A version: v1.8.5
closed with the note: now i developed title-length-counter plugin with help of @pupi1985

1 Answer

+3 votes
by
selected by
 
Best answer

You could either modify the static HTML that is generated or dynamically apply the listener using vanilla JavaScript or jQuery. I'd recommend the latter.

You can just add the needed code to the body_footer key of the content array like so:

if (!isset($qa_content['body_footer'])) {
    $qa_content['body_footer'] = '';
}
$qa_content['body_footer'] .= '<script>//your code</script>';

Note I'm being defensive on how I treat the body_footer array key presence.

Using JavaScript you can also add a <p> after the text input of the title.

You can also get the maximum length of the title using qa_opt('max_len_q_title'). Again, echo that output inside your script tags.

by
thnx... pupi1985
but i still have questions

how to to add a <p> tag after title field?

how to i get the value of Max length of title which is set in admin panel?
by
+1
Funny thing, I just read the title, saw the image and answered. Totally missed the rest of the questions in there :)
...