cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
TSteinbis
Level 2

Validating user entered proper time format in dialog data filed

To anyone:
I have created a custom dialog with serveral data fields for the user to enter the relative data into. One being "Start Time", which is a custom label. It is simply a text box where the user needs to enter the time they wish to have a function start in sql server. The time must be entered in military format. I want to validate the time is entered correctly by the user. Ultimately, I would like the installer to check the string entered into the data field to have 6 numeric characters only. After validating the number of characters, I want the installer to validate that the time entered is a real time (ex. of a wrong time: 260000). I want a message box to appear specifying the error and then when "OK" is clicked upon, the dialog does not advance, but provides the user to correct the mistake. The function to be executed at said time requires a Start Time and an End Time. If I place a bDone = True at the top of the code block then an if(svValue =...) then MessageBox("error", WARNING); bDone = False at the end, it works. But I need to do this in two places. I need to check to see if the start time is entered properly (one validation), then I need to check and see if the End Time is entered properly (second validation). Here it is:

bdone = true;
CtrlToText(svDialogID, RES_MAINT_START_HOUR, "");
TextToString(svValue, "");
if (StrLength(svValue) < 6) || (StrLength(svValue) > 6)then
MessageBox("There is an error in the way the 'Start Time' and/or the 'End Time' was entered. " +
"Example for 12:15:30 AM: '121530' ", WARNING);
bDone = FALSE;
endif;


bdone = true;
CtrlToText(svDialogID, RES_MAINT_END_HOUR, "");
TextToString(svValue, "");
if (StrLength(svValue) < 6) || (StrLength(svValue) > 6)then
MessageBox("There is an error in the way the 'Start Time' and/or the 'End Time' was entered. " +
"Example for 12:15:30 AM: '121530' ", WARNING);
bDone = FALSE;
endif;


This was my original thinking to simplify the process, but it does the one validation at the top and automatically advances after showing the messagebox rather than giving the user the ability to correct his/her entry. If I remove the first validation, the second one behaves the way I want it to. However it only behaves with regard to the second entry not the first. Anyone have a any ideas?
Labels (1)
0 Kudos

(1) Reply
ch_eng
Level 7

Perhaps this is what you are looking for?

bdone = true;
CtrlToText(svDialogID, RES_MAINT_START_HOUR, "");
TextToString(svValue, "");
if (StrLength(svValue) < 6) || (StrLength(svValue) > 6)then
MessageBox("There is an error in the way the 'Start Time' and/or the 'End Time' was entered. " + "Example for 12:15:30 AM: '121530' ", WARNING);
bDone = FALSE;
else
CtrlToText(svDialogID, RES_MAINT_END_HOUR, "");
TextToString(svValue, "");
if (StrLength(svValue) < 6) || (StrLength(svValue) > 6)then
MessageBox("There is an error in the way the 'Start Time' and/or the 'End Time' was entered. " + "Example for 12:15:30 AM: '121530' ", WARNING);
bDone = FALSE;
endif;
endif;


HTH
0 Kudos