[英]Stratus form for SharePoint. compare inputs after clicking Submit button
I got this great form for SharePoint from Stratus form to implement it on SharePoint 2013. I got it working, but would like to add extra validation and it does not recognize or something else is not working, because when I click submit, the form submits even without matching input.我从 Stratus 表单获得了这个很棒的 SharePoint 表单,以在 SharePoint 2013 上实现它。我让它工作了,但想添加额外的验证,但它无法识别或其他东西不起作用,因为当我单击提交时,表单提交即使没有匹配的输入。 Following is the code snippet.
以下是代码片段。 I am not sure how to add proper validation to input and sum.
我不确定如何为输入和总和添加适当的验证。
function CompareInputhpurs(){ var inputTotalHours = document.getElementById("totalHours").value; var sumTotalhours = document.getElementById('Total'); var comfirm = false; if(inputTotalHours===sumTotalhours){ comfirm=true; } else { alert("Total hours worked does not match.Please input correct total hours."); comfirm =false; } } function SubmitForm(){ //When the form is submitted store it to the specified list //also pass as in the x and y offset of error messages for elements //this allows you to change their location in reference to the form field $("#timesheetDiv").StratusFormsSubmit({ listName: "DailySummary", errorOffsetTop: 0, errorOffsetLeft: 5, completefunc: function(id) { CompareInputhpurs(); alert("Save was successful. ID = " + id); //window.location = window.location.pathname + "?formID=" + id; } }); }
<td> <label class="thisLabel" for="time" >Total hours worked:</label> <input listFieldName="TotalHours" id="totalHours" class="inputClassSmall" validate="validNumber"/> </td> <div class="rTableRow"> <div class="rTableCell"></div> <div class="rTableCell"></div> <div class="rTableCell"><label id="sumHours" class="thisLabel">Total hrs:</label><p id="Total"></p></div> </div> <input class="buttonClass" type="button" onclick="SubmitForm();" value="Add/Update Time Entry" />
You should call CompareInputhpurs before StratusFormsSubmit if you want to do client side validation.如果您想进行客户端验证,您应该在 StratusFormsSubmit 之前调用 CompareInputhpur。
function SubmitForm(){
CompareInputhpurs();
//When the form is submitted store it to the specified list
//also pass as in the x and y offset of error messages for elements
//this allows you to change their location in reference to the form field
$("#timesheetDiv").StratusFormsSubmit({
listName: "DailySummary",
errorOffsetTop: 0,
errorOffsetLeft: 5,
completefunc: function(id) {
alert("Save was successful. ID = " + id);
//window.location = window.location.pathname + "?formID=" + id;
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.