AnsweredAssumed Answered

Validation via Script - how to prevent tabbing to next field

Question asked by miw on Dec 20, 2010
Latest reply on Dec 20, 2010 by miw

Title

Validation via Script - how to prevent tabbing to next field

Post

I have a field that I want to validate via a script and not in the field definition.  This allows me some better control and flexibility in what kind of input can be accepted (also, I found that he validation through the field definition in a table only validates when the record is being saved and not during the input process).

I can get my script to perform the validation properly when I have a script to trigger upon OnObjectExit.   But if I exit the field by tabbing (which I want to be able to do, especially if the input is valid) once my script is run, I cannot get it to focus back on the invalid field - instead the layout goes to the next field in the tab order.  How can I get my script and end result to retain the focus on the subject field?

If [Record::PeriodStart >= 0 and Record::PeriodStart <= Year(Get(CurrentDate))]
     Go to Next Field
Else
     Show Custom Dialog ["Invalid Input"; "The Start Year should be numeric with a date range of 0 to "& Year(Get(CurrentDate))  [[Button 2 will accept the erroneous input as is and Button 3 will go back to revise input]]
End If
If [Get (LastMessageChoice)=2
     # accepts even erroneous inputs
     Go to next field
     Refresh window
     Halt Script
End If
If [Get (LastMessageChoice)=3
     Set Field [Record::PeriodStart; ""]
     Go to Field [Record::PeriodStart]
     Refresh Window
End If

Outcomes