Smashley Posted June 23, 2017 Report Share Posted June 23, 2017 I'm looking for a way to format a virtual field as mm/dd/yyyy. I'm passing the virtual field value to a date field in the subsequent datapage, and I need to enforce the date format. (I have a calendar pop-up option enabled for the virtual field, but I want to also enforce the format if they type in the date). Caspio support confirmed this is not a standard feature and would require custom coding (for which they suggested I come here:) Anybody know how this can be done? Thank you in advance:) Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 30, 2017 Report Share Posted June 30, 2017 You can use the code below in your submission page to cast input: <script> document.getElementById('Submit').onmouseover = function (){ var mydate = document.getElementById('InsertRecordDate').value; var date = new Date(mydate); var day = date.getDate(); var month = date.getMonth()+1; document.getElementById('InsertRecordDate').value = (month.toString().length === 1 ? "0" + month : month) + '/' + (day.toString().length === 1 ? "0" + day : day) + '/' + date.getFullYear() } </script> Replace Date in "InsertRecordDate" with your Date Field Name. This code should go to the footer of the page in Source mode. Quote Link to comment Share on other sites More sharing options...
Smashley Posted August 20, 2017 Author Report Share Posted August 20, 2017 Thanks for your response May I've tried your script but I'm not seeing any change in behavior in my application... If you have time to look at this more, here's some clarification: I'm using two datapages -- First datapage collects training class info.(example data: Ladder Safety, 08/19/2017) Second datapage allows user to select names from a list of employees and (by clicking "add" one by one) add them (with class info) into a training attendance records table.(example data: John Smith, Ladder Safety, 08/19/2017; Mark Jones, Ladder Safety, 08/19/2017; etc.) In the first datapage, the fields are virtual, and then passed on to the next datapage (where they are hidden but preloaded for every employee name selected) Ultimately I really want to be able to prevent the user from progressing to the second datapage if the date on the first datapage was entered in the incorrect format. I tried using your script on both datapages with no success... (I put it in the footer [source mode], and tried using both "InsertRecordVirtual1" and "InsertRecordClass_Date" as the date field references). Any other suggestions? Did I use your script correctly? Thanks a lot for your time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.