Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 AJAX by Matt Gibbs, Dan Wahlin; ISBN: 9780470109625
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 AJAX ISBN: 978-0-470-10962-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2008, 04:54 AM
sim sim is offline
Registered User
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default return value of Confirm in javascript not Working onClientClick

return value of Confirm in javascript not Working OnClientClick of button.
button is placed in updatePanel (AJAX).
JavaScript code for confirm is also in updatePanel(AJAX)

function chkleave()
var dat1 = document.getElementById("txttxtleavestartdate").value;
if (dat1.length != 10) 
var dat2 = document.getElementById("txttxtleaveenddate").value;
if (dat2.length != 10) 
if(Math.floor((new Date(dat2)-new
if (!confirm("Your Leave days are exceeding pending leaves. \n Your extra leaves will be considered 'Leave Without Pay'. \n Are you sure you want to send it for approval."))
return false;
<asp:ButtonID="btnSubmit"OnClientClick="return chkleave()"ValidationGroup="vali"CssClass="txtBox"BackColor="#1B3091"Font-Bold="True"ForeColor="White"runat="server"Text="Submit"OnClick="btnSubmit_Click"/>

Last edited by sim; December 19th, 2008 at 02:26 AM.. Reason: made changes after response but still not working
Reply With Quote
  #2 (permalink)  
Old December 18th, 2008, 04:40 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

You are missing a space between return and false so you are always getting a JavaScript error
and since apparently you don't have JavaScript debugging turned on you can't see that error.
The result is that the JavaScript code is effectively ignored.

You also do *NOT* do
return true;
when the confirm is true or the confirm is not invoked, so you can't even predict what will happen.
Yes, generally if you omit a return value from a JS function the result is the same as if you
returned true, but you can *NOT* guarantee that. If the function should return a value,
make sure that it ALWAYS does so, no matter what.

Your code should end with
    return true;

Last edited by Old Pedant; December 18th, 2008 at 04:43 PM..
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Submit Button w/OnClientClick: Not Working kwilliams ASP.NET 2.0 Professional 4 August 25th, 2008 12:00 PM
JavaScript Confirm Box ricespn Classic ASP Basics 1 January 20th, 2007 12:48 AM
Javascript Confirm Message box itHighway Javascript How-To 5 September 25th, 2006 02:51 AM
Javascript Confirm dialog difficulty ayrton Javascript 1 May 20th, 2005 03:34 AM
need Confirm() with Yes/No buttons in JavaScript ehelpcornet ASP.NET 1.0 and 1.1 Basics 1 June 3rd, 2004 07:32 AM

All times are GMT -4. The time now is 04:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.