PDA

View Full Version : How to make a field becomes conditional required.


ABC123

EdwardTsai
09-15-2009, 06:47 AM
I have a backend MSSQL table with Customer information which contains customer name, consignee name, billing & shipping addresses and they are put in a datagrid. I want to make the consignee name and its address become required fields if "BillSame" field is not checked (BillSame is in "bit" format in MSSQL table, default value is "False"), if it is checked, those fields become non-required fields.

I put below codes in Validation Xbasic under Display Settings of Consignee Name field, but is doesn't work.

function validate_ConsigneeName as p (e as p)
'Sample validation function.
'Data for the current row is available in 'e.data'. For example, e.data.firstname, e.data.lastname

if e.data.BillSame = "False" .and. e.data.ConsigneeName ="" then
validate_ConsigneeName.hasError = .t.
validate_ConsigneeName.errorText = "Consignee Name is required."
end if
end function

Could someone help? Thanks!