iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Stop a Client Side Event With a Validator

104 22
    • 1). Open your programming software of choice and open the page that must contain the validator.

    • 2). Drag-and-drop a CustomValidator control onto the page and set its ClientValidationFunction equal to "sampleFunction:"

      <asp:CustomValidator id="CustomValidator1" runat="server"
      OnServerValidate="TextValidate"
      ControlToValidate="TextBox1"
      ErrorMessage="Text must be 8 or more characters."
      ClientValidationFunction="sampleFunction">
      </asp:CustomValidator>

      (See References 3)

    • 3). Write a "sampleFunction()" method to disable the target event, using JavaScript's native ".removeEventListener()" method:

      <script type="text/javascript">
      function sampleFunction(){
      element.removeEventListner('click',functionToDisable);
      }
      </script>

      The above code, for example, stops the client side event named "functionToDisable's" click event.

    • 4). Save your work. Open the Web page in an Internet browser to ensure it performs as expected.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Health & Medical"

Leave A Reply

Your email address will not be published.