| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Tue Feb 15, 2005 6:34 pm    Post subject: How can I submit (autopost) the form right after a date is picked (onchange)? |   |  
				| 
 |  
				| To submit a static form named as "testForm", you may use the following code in plugins.js: 
  	  | Code: |  	  | function fAfterSelected(y,m,d) { gContainer.document.testForm.submit();
 }
 | 
 For PopCalendarXP, it could be even simpler (you don't have to know the name of the form):
 
  	  | Code: |  	  | function fAfterSelected(y,m,d) { gdCtrl.form.submit();
 }
 | 
 If you are working with ASP.NET with client validators disabled, you could replace the above function with the following one:
 
  	  | Code: |  	  | function fAfterSelected(y,m,d) { if (gdCtrl.onchange) gdCtrl.onchange();
 }
 | 
 This way the authentic ASP.NET event handler will be called after a date is picked via the PopCalendar so as to maintain a consistent AutoPostBack behavior.
 
 NOTE:
 Unfortunately, we found a bug in the WebUIValidation.js provided by ASP.NET 1.x that will cause an error if the client validators are turned on.
 
 To fix it, you need to patch the WebUIValidation.js under \Inetpub\wwwroot\aspnet_client directory.
 1st, find the ValidatorOnChange function and replace it with following one:
 
  	  | Code: |  	  | function ValidatorOnChange(el) { var vals = el.Validators;
 var i;
 for (i = 0; i < vals.length; i++) {
 ValidatorValidate(vals[i]);
 }
 ValidatorUpdateIsValid();
 }
 | 
 2nd, find the following string:
 
 and replace it with 	  | Code: |  	  | var func = new Function("ValidatorOnChange(); " + ev); | 
 
 Now, the error should be gone. 	  | Code: |  	  | var func = new Function("ValidatorOnChange(this); " + ev); | 
 
 However, this patch solution won't work in ASP.NET 2.0, because the WebUIValidation.js is now dynamically generated with that bug buried deep in its engine. We don't know when Microsoft will fix it, so we'd suggest turning off the onchange ASP.NET validator on the date field totally. It shouldn't affect your form's validity, because the date picked via the calendar is always in a good format.
 
 Finally, please note that this is a common issue that affects every javascript product on the market, not just PopCalendarXP.
 _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  |