Stopping onclick from firing when onclientclick is false?

前端 未结 5 842
我在风中等你
我在风中等你 2020-11-30 10:45

Is it possible to use the onclientclick property of a button to do a clientside check. If the check returns true, then fire the onclick

5条回答
  •  攒了一身酷
    2020-11-30 11:48

    Yes you can, In onclientClick function call use preventDefault()

    function onclientClickFun(e)
    {
      if(!IsValidationSuccess)
     {
       e.preventDefault();
     }
    
    }
    

    OR

    function onclientClickFun(e)
    {
      if(!IsValidationSuccess)
     {
       return false;
     }
    
    }
    

提交回复
热议问题