# create myalert as Javascript function my $myalert = $mech->declare(<eval_in_page('validateIpSettings()', { alert => $myalert });