0

We have a custom list form that we are trying to save, validate, and redirect. We can get the button to save and validate, but not redirect. And vice versa. We have tried several variations on the lines in red, all with either no save or no redirect. We are also using this custom list form on a custom master page.

Is there something that we are doing wrong?

<script>
$(document).ready(function() {
var button = $("input[id$=SaveItem]");
// change redirection behavior
    button.removeAttr("onclick");
    button.click(function() {
        var elementName = $(this).attr("name");
        var aspForm = $("form[name=aspnetForm]");
        var oldPostbackUrl = aspForm.get(0).action;
        var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl);
        var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "custompageurl.aspx")

        if (!PreSaveItem()) return false;
        if  (SPClientForms.ClientFormManager.SubmitClientForm('WPQ1')) return false;
        if (!Page_ClientValidate()) return false;
        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));
    }); 
});
</script>
  • have you tried using window.location.href=redirecturl? – Amal Hashim Apr 27 '15 at 16:43
  • this saved it, but it did not redirect. validation still does work though. – Mike Adams Apr 27 '15 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.