Form_CustomValidate

This public forum is for user-to-user discussions of ASPMaker. Note that this is not support forum.

Form_CustomValidate

Postby emoffster » Fri Oct 06, 2017 6:51 pm

I have a checkbox field, with four options, and if ANY of the four options is checked I want to make another field required.
How can I make it happen the way I want it?

Function Form_CustomValidate(CustomError)

If Table.CheckboxFld.FormValue is NOT NULL AND ISNULL (Table.RequiredFld.FormValue) THEN
Form_CustomValidate = False
CustomError = "You have to fill out RequiredFld"
Else
Form_CustomValidate = True
End If

End Function
emoffster
 
Posts: 16
Joined: Mon Jan 21, 2013 5:14 pm

Re: Form_CustomValidate

Postby Webmaster » Sat Oct 07, 2017 7:53 am

To check if a value is not null, use:

If Not IsNull(...) Then
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm

Re: Form_CustomValidate

Postby emoffster » Mon Oct 09, 2017 1:05 pm

Thanks, but still doesn't validate. I'm able to add anyway, although checkbox is checked and the required field is empty.

This is the full validation code. Everything works, but not the third IF.

Function Form_CustomValidate(CustomError)

If Logg.Produktkontroll.FormValue = 0 AND ISNULL (Logg.VerifieringstypID.FormValue) THEN
Form_CustomValidate = False
CustomError = "Verify type cannot by empty"

ElseIf Logg.Sorterat.FormValue = 1 AND ISNULL (Logg.SparratLager.FormValue) THEN
Form_CustomValidate = False
CustomError = "Sparrat can not be empty"

ElseIf ISNULL (Logg.AnstnrVerifiering.FormValue) AND Not ISNULL (Logg.VerifieringHur.FormValue) THEN 'this one doesn't work, what could be wrong
Form_CustomValidate = False
CustomError = Verified by cannot be empty"

Else
Form_CustomValidate = True
End If
End Function
emoffster
 
Posts: 16
Joined: Mon Jan 21, 2013 5:14 pm

Re: Form_CustomValidate

Postby Webmaster » Mon Oct 09, 2017 5:42 pm

To debug your codes, add appropriate Response.Write codes. For example:

Response.Write "Field 1 form value: " & <Field1>.FormValue & "<br>"
Response.Write "Is Null Field 1: " & IsNull(<Field1>.FormValue) & "<br>"
Response.Write "Field 2 form value: " & <Field2>.FormValue & "<br>"
Response.Write "Is Null Field 1: " & IsNull(<Field2>.FormValue) & "<br>"

If ... Then
...
ElseIf IsNull(<Field1>.FormValue) And Not IsNull(<Field2>.FormValue) Then
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm

Re: Form_CustomValidate

Postby emoffster » Mon Oct 09, 2017 8:59 pm

Thanks, finally resolved it.
emoffster
 
Posts: 16
Joined: Mon Jan 21, 2013 5:14 pm


Return to General Discussion (ASPMaker)