ASP.NET 1.1 & Javascript Validation: Return false but server code still runs!?!?

Hey Experts,

I'm attempting to validate an asp.net form by way of a javascript function. The problem is this:
Even though my jscript function returns false, the server side code still runs.  

My JScript is being called like this:

btn_save.Attributes.Add("onClick", "checkvals();")


To troubleshoot, I reduced the javascript to it's simplest possible form:

function checkvals()
{
return  false;
alert("WRONG!!");
}

When I click the button, the alert pops up, I click okay and then the server side code runs.

What's going wrong here???

Thanks in advance,

RFR
RunForrestRunAsked:
Who is Participating?
 
nauman_ahmedCommented:
need to add return:

btn_save.Attributes.Add("onClick", "retirn checkvals();")

-Nauman.
0
 
RunForrestRunAuthor Commented:
Thanks Nauman . . . that's a quick and easy 500pts for you . . . . . much obliged.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.