View Single Post
  #3 (permalink)  
Old 10-15-2007, 08:16 AM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Question Re: How to call a javascript function in a client side click?

Hi,

I have a asp.net page. I have a asp.net button control. I need to call a javascript for some validation and then server side code on click of this button. The server side code(on button click event is fired properly) is being called. But the javascript validation does not happen

My button html script is

<asp:button id="btnConvert" style="Z-INDEX: 102; LEFT: 352px; POSITION: absolute; TOP: 408px"
runat="server" BackColor="#FFC080" Height="32px" Width="137px" Text="Convert" Font-Bold="True"></asp:button>

My code behind page_load event has call to javascript function as below

btnConvert.Attributes.Add("onclick","javascript:re turn fnValidate();");

My javascript function code is

var result = true;
if(window.document.getElementById('CheckK').checke d == false &&
window.document.getElementById('CheckL').checked == false &&
window.document.getElementById('CheckM').checked == false &&
window.document.getElementById('CheckN').checked == false &&
window.document.getElementById('Check35').checked == false &&
window.document.getElementById('Check50').checked == false)
{
alert("Please select at least one Compressor Size.");
result = false;
}
else
{
if(window.document.getElementById('ChkAutoFemaleDa ta').checked == false &&
window.document.getElementById('ChkAutoMaleData'). checked == false &&
window.document.getElementById('ChkAutoOverallData ').checked == false &&
window.document.getElementById('ChkVerFemaleData') .checked == false &&
window.document.getElementById('ChkVerMaleData').c hecked == false &&
window.document.getElementById('ChkVerOverallData' ).checked == false)
{
alert("Please select at least one Check Box for the type of data.");
result = false;
}
else
{
result = true;
}
}
return result;
}

The javascript validation never gets fired. Please help.
__________________
Krishnakumar.S
Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily
Reply With Quote