zoukankan      html  css  js  c++  java
  • SharePoint提交前有效性验证

    In this article we will see how to implement client side validation in SharePoint list with out using SharePoint designer.

    For this follow the below steps

    1. 找到需要有效性验证的页面,如NewForm.aspx或者EditForm.aspx
      在URL后面输入红色部分:(http://mysite/ Lists/job/NewForm.aspx?pageview=shared&toolpaneview=2)可以进入编辑模式.
    2. 添加一个 “content editor web part” 并且修改这个web part,在代码视图中输入
    3. Add the below script
      1.<script language="javascript">
      2.function PreSaveAction()
      3.{
      4.//add your JavaScript code here and return true / false
      5.}
      6.</script>

    如:

    <script language="javascript">
    function PreSaveAction()
    {
    //add your JavaScript code here and return true / false
          var elm2 = document.getElementById("idAttachmentsTable");
             if (elm2 == null || elm2.rows.length == 0)
    {
                        alert('Please attach file!');
                 return false;
    }
                    else
    {
                        return true;  
    }
    }
    </script>

     以上代码的作用为:在提交的时候验证附件是否为空,如果空,提示必须添加附件。

    另外还可以通过http://www.codeplex.com/SPJsLib杜总发布的JS方案来检测。

  • 相关阅读:
    高阶函数
    如何理解data URL?
    JS对象的创建方式
    数组中的map方法
    奇怪的 Javascript
    什么场景不适合箭头函数
    协方差矩阵学习[转载]
    PAT 1140 Look-and-say Sequence [比较]
    PAT 1089 Insert or Merge[难]
    PAT 1096 Consecutive Factors[难]
  • 原文地址:https://www.cnblogs.com/ceci/p/1728731.html
Copyright © 2011-2022 走看看