How to use JavaScript in Perl Object Oriented

i am new to Perl CGI Object oriented.

I want to use some java script in my Perl CGI but i am not able to do that.

I am using Submit button then via param() i am getting all field parameters.

But i want to validate all fields first then i want to move. But Use of Java script, i don't know

From the beginning, Just for everything, I refer to the cpan/perldoc documentation for CGI and fortunately I get everything I want.

Below is an example I am using in one of my CGI script.

my $cgi = new CGI;

my $cookie = $cgi->cookie(-expires=>'now');

print $cgi->header(-type => "text/html", -charset => 'ISO-8859-1',-cookie=>$cookie);
print $cgi->start_html(-title=>'my Title',
						-style=>{'-src' => "${DOC_ROOT}" . 'css/style.css'},
						-head=>$cgi->Link({-rel=>'shortcut icon',-href=>'favicon.ico'}),
						-script=>{-type=>'text/javascript', -src=>"${DOC_ROOT}" . 'js/toggle.js'}
					);

## body goes here


print $cgi->end_html();

Please visit cpan for CGI documentation. You will get everything there.