First you need to understand will your form work with Javascript disabled or not. I recommend to disable Javascript in your browser and submit your form after that.
If the form will work then all you need is just submit your data with
WWW::Mechanize:
$mech->submit_form(
with_fields => {
login => "somelogin",
password => "somepassword",
},
);
If you can't submit your data from the browser with Javascript disabled you can either emulate same POST request in your code or you can use browser automation (like
WWW::Mechanize::PhantomJS)