Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
868 views
in Plugins by
recategorized by
Hi,

I have a Plugin Page of mine, which essentially takes some input from the User, process it, and show some results.

 

I want to write some code for Validation of my Form in Javascript. Can anyone advice me, what would be the best way to do that? There is an array that I receive by calling the qa_content_prepare() method (I took a clue from the Example Plugin Code provided with Q2A), and then I put my form Content to this array like

$qa_content['form']=array(

...);

I would like to know, is there a way to add my Script, or say a line like "<script src=......." in the Head of My Page using this Array? If yes, is this the best way of doing it, or there is some standard way for this?

1 Answer

+1 vote
by
Something like:

            $qa_content['script_lines'][] = array('alert("hello, world!");');

or

            $qa_content['script_onloads'][] = 'alert("hello, world!");';

You could also just implement a custom layer for your plugin and add to head_script() or head_custom() function.
by
Thanks a lot.. Layer Option suits me in a much better way. I already have a Layer in my Plugin, I can plug the code there :) :)
...