Rob's TIMSS Blog

My discoveries and ramblings of TIMSS/Personify.

Saturday, May 27, 2006

Extender Scripting: Birth Date Validation

Someone at TAUG asked if it was possible to do validation on a customer's birth date. You can use the script below in the OnValidated event for the Birth Date field on the Individual screen (CUSoo1I) to do just that.

Public Sub dtBirthdate_OnValidated ( ByRef MyForm As Object, ByRef MyControl As Object)
dim Age as String

If Myform.getformControlByName("dtBirthdate").text = "(none)" Or Myform.getformControlByName("dtBirthdate").text= "" Then
Exit Sub
End If
Age=year(now())-year(Myform.getformControlByName("dtBirthdate").value)
If Age>100 or Age<15 then
MsgBox("The age of the person is "+Age+". Please make sure the birth date is correct.",MsgBoxStyle.Information, "TIMSS - Information")
End If
End Sub


If the person is over 100 or under 15 (ok, the calculation isn't exact but it's close enough) the user will get the following box:



Applies to: TIMSS6

0 Comments:

Post a Comment

<< Home