Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

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
0
RunForrestRun
Asked:
RunForrestRun
1 Solution
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now