You can add you javascript code to NewForm.aspx.
Place this code in the newform.aspx page under the line
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<!-- dkf code modified to redirect page end -->
</div>
<div class="mainContent">
<!-- dkf code modified to redirect page -->
<script type="text/javascript" language="javascript">
function PreSaveAction() {
var srcUrl=GetSource();
var newSrcUrl = "http://www.yournewaddress.com";
var i = aspnetForm.action.lastIndexOf(srcUrl);
aspnetForm.action = aspnetForm.action.substring(0,i) + newSrcUrl ;
return true;
}
</script>
<!-- dkf code modified to redirect page end -->
Another option would be like this:
From the Ribbon click on List -> Form Web Parts -> Default New Form
Click on Add a Web Part -> Media and Content -> Content Editor
Edit the Content Editor web part and put in the link to the JavaScript file
Sharepoint 2013. Add JS to NewForm.aspx of a list
https://stackoverflow.com/questions/10351162/add-javascript-to-newform-for-splist-in-sharepoint