I am having an issue about redirecting users to a different URL on Save or Cancel button. First of all I have used below code to change SharePoint list new item form's Save button to Submit.
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("ChangeSPSavetoSubmit()");
function ChangeSPSavetoSubmit()
{
var inputs = document.getElementsByTagName("input");
for(i = 0; i<inputs.length; i++)
{
if(inputs[i].type == "button" && inputs[i].value == "Save")
{
inputs[i].value = "Submit";
}
}
}
</script>
Above is a working solution, its added as a script editor web part on new item form. Below is the code I added as well on the new item form to redirect users to a different page/URL on Submit/Cancel button clicks.
<script src="/SiteAssets/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[value=Submit]').click(function() {
window.location.replace("https://***.sharepoint.com");
});
$('input[value=Cancel]').click(function() {
window.location.replace("https://***.sharepoint.com");
});
});
</script>
The functionality works when clicked on Cancel button but not when clicked on Submit button, can someone please help with the correct code. Thanks in advance, FYI I am working with O365/SPOnline.