Introduction

One of the best practices in any application development is proper client-side validation. Typically a developer using web-based forms for client pages in workflow processes will either use standard ASP.NET web pages or K2.net™ 2003 SmartForms. The following example allows developer to implement client-side validation on both VS.NET web pages and K2.net™ 2003 SmartForms.

For ASP.NET developers who would like to execute client-side script prior to a K2 SmartForm control posting to the server can use the script below:
<HTML>
  <HEAD>
    <title></title>
  </HEAD>
  <body MS_POSITIONING="GridLayout" onload="return window_onload()">
    <form id="Form2" method="post" runat="server" enctype="multipart/form-data">
      <K2:K2Button id="K2Button1" style="Z-INDEX: 112; LEFT: 280px; POSITION: absolute; TOP: 216px" runat="server" Text="Submit" Type="PlanButton"></K2:K2Button>
    </form>

    <!-- This script section must go after your closing form tag -->
    <script language="javascript" type="text/javascript">
      var bW3Compliant = (document.getElementById) ? 1 : 0;
      if(bW3Compliant)
      {
        document.Form1.K2Button1.onclick = K2Button1_onclick;
      }
      function K2Button1_onclick()
      // fires prior to server posting.
      {
        return (confirm("Are you sure you would like to start this process?")) ? true : false;
      }
    </script>
  </body>
</HTML>