Connecting Tech Pros Worldwide Forums | Help | Site Map

How to call two javascript functions onclick of a submit button?

Newbie
 
Join Date: Feb 2008
Posts: 4
#1: Feb 26 '08
Hello every one,

I am using VS 2005, I am having selection of From & To dates in every page of project, for validation of these two fields I written common javascript function in master page, I am calling this function on attributes property of button.
Now I want to validate other controls of the pages too, which has to be written in that page itself. So how can I achieve this?

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Feb 26 '08

re: How to call two javascript functions onclick of a submit button?


Quote:

Originally Posted by ameetijantakar

Hello every one,

I am using VS 2005, I am having selection of From & To dates in every page of project, for validation of these two fields I written common javascript function in master page, I am calling this function on attributes property of button.
Now I want to validate other controls of the pages too, which has to be written in that page itself. So how can I achieve this?

Either you create one Javascript function, say called validateForm, and you call all those functions from that function or you call each of the functions separating them by a semi-colon.
shweta123's Avatar
Expert
 
Join Date: Nov 2006
Location: India,Pune
Posts: 686
#3: Feb 26 '08

re: How to call two javascript functions onclick of a submit button?


Hi,

You can call the 2 javascript functions on onClick event of submit button like this way :
btnSubmit.Attributes.add("onClick","function1();fu nction2();")

Quote:

Originally Posted by ameetijantakar

Hello every one,

I am using VS 2005, I am having selection of From & To dates in every page of project, for validation of these two fields I written common javascript function in master page, I am calling this function on attributes property of button.
Now I want to validate other controls of the pages too, which has to be written in that page itself. So how can I achieve this?

Newbie
 
Join Date: Feb 2008
Posts: 4
#4: Feb 27 '08

re: How to call two javascript functions onclick of a submit button?


Quote:

Originally Posted by shweta123

Hi,

You can call the 2 javascript functions on onClick event of submit button like this way :
btnSubmit.Attributes.add("onClick","function1();fu nction2();")


Hi Shweta,

This is Ameet, I tried this
btnSubmit.Attributes.Add("onclick", "return validatesas();return check();");

but only 1st function validatesas() is executing, if I replace function check() on 1st position, then only check() is executing.
Reply