I am trying to add one new custom button near the save button on a newform.aspx of my list in a SharePoint Online site.
Here is the current content editor web part (CEWP) code in the newform.aspx, which needs improvement:
<script src="https://code.jquery.com/jquery-1.10.2.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
// for Save button
alert(' docu ready');
var saveCancelText='<input type="button" id="saveBtn" value="Save1233" class="ms-ButtonHeightWidth"></input> <input type="button" id="cnclBtn" value="Cancel" class="ms-ButtonHeightWidth"
onclick='javascript: if( PreSaveAction() )
{ddwrt:GenFireServerEvent('__commit')}' ></input>';
$(".ms-formtoolbar > tbody > tr").append(saveCancelText);
Running the code fails to show the custom button because of onclick event
` onclick='javascript: if( PreSaveAction() )
{ddwrt:GenFireServerEvent('__commit')}'`
How can I call the onClick event inside document.ready? I can't call this on presaveaction().
Any idea how I can trigger an event on click of this custom save button and call PreasaveAction and perform my custom validation? I want to redirect to a different page, editform.aspx with an ID in the querystring parameter.