Mokshasri

Mokshasri

  • NA
  • 31
  • 0

onclientclick not working- asp.net 3.5

Dec 6 2009 4:22 PM

Hi!
  I have the following in the head section of the .aspx file:
 
<
script language="javascript" type="text/javascript">
function Validations()
{
if(document.getElementById("TxtboxTo").Value== "")
{
alert(
'Enter atleast one email ID');
document.getElementById(
"TxtboxTo").focus();
return false;
}
else if(document.getElementById("txtboxmessage").value == "")
{
alert(
'Please enter Password');
document.getElementById(
"txtboxmessage").focus();
return false;
}
else
{
return true;
}

}
 
And I am calling this javascript using onclientclick="return Validations();"
Also, I have onclick event for the button.
The problem, is that javascript function is not getting executed instead directly the onclick event is getting fired. I have tried onclientclick="return javascript:Validations();", onclientclick="javascript:Validations();", onclientclick=" Validations();", onclientclick=" Validations(); return;" etc., but nothing is working.
 
However, when I tried the following javascript:
function
Check()
{
alert(
'Testin');
}
</script>
and onclientclick="Check();", it is working perfectly.
 
Can anyone suggest me what I am doing wrong in Validations javascript?
How to make onclientclick and onclick both work so that only after javascript validations are complete to true then only onclick event gets fired.
Appreciate your quick response.
Thanks,
Mokshasri
 

Answers (3)