Expand my Community achievements bar.

Date field automatcailly changing when tabbing through other scripted fields

Avatar

Level 2
I have a form with a datetime field. The object is readonly. I format the field with javascript as yyyymmddhhmmss as a tracking number for the form. When tabbing through other fields with javascript the value changes to the current date time, like the code is being executed each time a scripted field is entered.



Any ideas how to prevent that? I just want the code to execute when the form is opened.



----- form1.sbfDirect_Pay.dteCurrentDate::ready:layout - (JavaScript, client) ----------------------



// Current Date in short-style date format.



// $.rawValue = num2date(date(), DateFmt(1, "))

var varCurrentTime = new Date();

var varYear = varCurrentTime.getFullYear();

var varMonth = varCurrentTime.getMonth() + 1;

var varDay = varCurrentTime.getDate();

var varHour = varCurrentTime.getHours();

var varMin = varCurrentTime.getMinutes();

var varSec = varCurrentTime.getSeconds();



if(varMonth<10) varMonth = "0" + varMonth;

if(varDay<10) varDay = "0" + varDay;

if(varHour<10) varHour = "0" + varHour;

if(varMin<10) varMin = "0" + varMin;

if(varSec<10) varSec = "0" + varSec;



// $.rawValue = year + "" + month + "" + day + "" + hour + "" + min + "" + sec;



dteCurrentDate.rawValue = varYear + "" + varMonth + "" + varDay + "" + varHour + "" + varMin + "" + varSec;
1 Reply

Avatar

Level 2
I think I just answered my own question. The code was in the layout:ready event. This area is executed each time the layout is modified. I moved the code to form:ready event.



:-)