I have some validation code that runs as client side js in a “Save” button. If all validations pass, then I want to set a couple date fields before saving the xpage to its data source. I’ve tried using
var currdate = new Date();
var dc = XSP.getElementById(“#{id:DateChg}”);
dc.value = currdate;
But, I get an error “this field is not a valid date”. I also tried parsing the currdate value into a string and saved that into the field, but got the same error.
Is there a special property of the currdate object I need to use? or, where have I gone wrong?
My DateChg field is a hidden input control, set as Date/Time.
Note it’s an input field of type text, and the value is also text.
Also, the XML produced makes it an inputText with a converter. I believe the converter is converting the javascript text value into a date when passed to the NotesDocument, and converting the date passed from the NotesDocument to a string for the HTML.
Saving the date as a string in a Text edit box produces the same error. It’s the date converter that’s producing the error message. Apparently, the dateconverter is called in the addOnLoad function, but I don’t know where this function is to even see why it’s producing the error.
It’s very frustrating as now I cannot save my document at all.
(Note: this is an app in development, not production, so not critical)
The addOnLoad is in xspClientDojo.js which, for a standard Notes install, will be in C:\Program Files\IBM\Lotus\Notes\Data\domino\js\dojo-1.3.2\ibm\xsp\widget\layout folder.
What is the date that you have stored in your Notes document? Also what is the server date format (as recorded in the Notes Log), and what is the date format on your browser? Check your Notes field settings on the form. These are the obvious things that spring to mind.
If none of these throw any light on the problem, post your code and I’ll see if I can spot anything.