How to call javascript function on button click

How to call javascript function on button click

  
Hello All,

I have button to save data on sql server. I have written javascript to validate some of the field, when I click on button i have to check validation first if all the field data in proper format then server side button click event should be fired.So how to call client side as well as server side methods for single button.


Thanks and regards,
 Pradip Chavhan
Solution
Hi Pradip,

In every button/Link you have the property Validation this method can be set to one of the following 3 options:
·        Server
·        Client & Server
·        None
As for the Server option there will be no client side validation and all the validation checks should be written in your Save action.

The Client & Server option will validate two aspects Client side: Mandatory fields and Datatypes. If these two aspects are seem valid then the server part of this validation will run and behave the same as if you would chose the Server option.

If you want to read anything more about how to validate End-User Inputs check this link: http://www.outsystems.com/help/servicestudio/9.1/index.htm#t=Web_User_Interface%2FValidate_End-User_Inputs.htm

Regarding your question: "How to call JavaScript function on Button Click" There are some ways to do this but the easiest way is the action "RunJavaScript" in the "HTTPRequestHandler" extension. 
Then you can do stuff like this:
 

Kind Regards,
Martijn Habraken
Solution
Hi Pradip,

Don't forget to return True from Javascript, as returning False will not call the Server-side action.