共享点表单验证,然后重定向到新URL

时间:2019-07-18 13:02:31

标签: sharepoint-2013

我有以下有效的代码,但是您可以帮我修改它吗,

它会在提交之前验证表单,默认情况下它可以工作,但是会带您回到列表。

图片和详细信息: https://social.technet.microsoft.com/Forums/sharepoint/en-US/c6ace657-425d-4918-841c-7b136a94562e/form-validation-and-redirect?forum=sharepointdevelopment

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
 <script>
 $(document).ready(function(){
     var targetURL = 'http://sp/Lists/Test/AllItems.aspx';
     //For Cancel Button
   $("input[value='Cancel']").click(function(event){
    //event.preventDefault();
    window.location.replace("http://sp/Lists/TestDetails/AllItems.aspx");
   })

     //For Save Button
       var saveButton = $("input[value='Save']");
       saveButton.removeAttr("onclick");
       saveButton.click(function() {             
             if (!PreSaveItem()) return false;
             if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')){
                window.history.pushState('redirectRrl', 'redirectRrl', 'http://sp/Lists/MyList/NewForm.aspx?Source='+targetURL+'');
                return false; 
             }

             var oldActionUrl = $('#aspnetForm').attr('action');
             var oldSource = GetUrlKeyValue("Source", true, oldActionUrl);           
             var newActionUrl = oldActionUrl.replace(oldSource, encodeURIComponent(targetURL));
             var elementName = $(this).attr("name");
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newActionUrl, false, true));
         });    
 });
 </script>

电子邮件未存储在具有以上代码的列表列中

0 个答案:

没有答案