Field Validation Hook Problems

Field Validation Hook Problems

Postby » Tue Nov 04, 2008 7:28 am

I am trying to validate several fields using the same field_validate function for each field. In testing, I am finding that the error from a previous field entry is still there in the current field. Example: Wages field where user keys 12345 would generate an error because the business rule is that a decimal is required in the third position from the right. The user can F7 to override the validation failure, rekey the field and continue to the next field. The next field, Holiday where user keys 28.10 which is correct, but the same error is displayed that occurred in the previous field. What am I missing in the script to reset the field_validate to clear the previous error and start over in each new field? I need to do this for four fields on the same form. Field_Validate code is below.

Function field_validate(values(),thisval)
'Completion Field Validation Function
'Return 1 if validation succeeds, or 0 if validation fails.
'If validation fails, set the variable 'message' to display a message in the statusbar.
Dim testval
Dim str1
Dim strDec
Dim strMessage
testval = ""
str1 = ""
strDec = ""
strMessage = ""
testval = Values(thisval)

'Check value
If Len(testval) > 0 And Len(testval) =< 3 Then
strMessage = "Value must be at least 4 long and contain a decimal. Press F7 and rekey."
Message = strMessage
field_validate = 0
Exit Function
ElseIf Len(testval)> 3 Then
str1 = Right(testval,3)
strDec = Left(str1,1)
If strDec <> "." Then
strMessage = "There must be a decimal in the third position from the right. Press F7 and rekey." + strDec
Message = strMessage
field_validate = 0
Exit Function
End If
Else
field_validate = 1
Exit Function
End If

End Function
Participant
 
Posts: 4
Joined: Fri Dec 15, 2006 1:06 pm

Postby » Tue Nov 04, 2008 7:33 am

I don't see you clearing the value of "Message" on the code path which indicates a successful validation.

Try adding a line to blank the validation error message by modifying the very end of your function as follows:

Code: Select all
Else
   field_validate = 1
   Message = ""    'validation was successful, so blank the validation error message
   Exit Function
End If
Stephen Bottomley
Senior Product Specialist
Tel: +44 (0)1223 226012
Participant
 
Posts: 675
Joined: Mon Jul 11, 2005 8:31 am
Location: Cambridge

Postby » Tue Nov 04, 2008 9:20 am

Thanks. I just tried that and unfortunately I still have the same result. Something is causing the message to stay, even after rekeying and F7 to override the failure.

I have also noticed that if nonvalid data is entered in the first field, the correct error message is generated. I rekey that field, then F7 and go to the next field. If I enter different nonvalid data in the next field, the correct error message is generated for that field. I rekey that field, then F7 and go to the next field. In the third field, I enter valid data, but the error from the previous field is still presented and I cannot exit the third field unless I F7 out of it and any other fields that I perform this field_validate function on.

Perhaps there is a setting that I should have checked or unchecked in the Completion setup? I am using Indicius 5.5 and Ascent 7.5 SP5.
Participant
 
Posts: 4
Joined: Fri Dec 15, 2006 1:06 pm

Postby » Tue Nov 04, 2008 9:26 am

Hi Sue,

Sounds like you need to discuss this issue with your technical support person. Please get in touch with your usual support contact.
Stephen Bottomley
Senior Product Specialist
Tel: +44 (0)1223 226012
Participant
 
Posts: 675
Joined: Mon Jul 11, 2005 8:31 am
Location: Cambridge

Postby » Tue Nov 04, 2008 9:29 am

Ok, thanks for trying to assist. I'll post whatever update I get from our vendor support.

Update: After talking with my vendor support, I was able to get the script to work with minor changes. The code now looks like that pasted below and I don't even need to F7 to override the validation error!

Function field_validate(values(),thisval)
Dim testval
Dim str1
Dim strDec

testval = ""
str1 = ""
strDec = ""

testval = Values(thisval)

'Check value
If Len(testval) > 0 And Len(testval) =< 3 Then
Message = "Value must be at least 4 long and contain a decimal."
field_validate = 0
Exit Function
ElseIf Len(testval)> 3 Then
str1 = Right(testval,3)
strDec = Left(str1,1)
If strDec <> "." Then
Message = "There must be a decimal in the third position from the right."
field_validate = 0
Exit Function
End If
End If
field_validate = 1

End Function
Participant
 
Posts: 4
Joined: Fri Dec 15, 2006 1:06 pm


Return to Indicius General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest