custom_validate with query

hy im have table:
id referralcode cust
1 yu789q yanuar
2 uijn67qq awan


how to use custome_validate with a query
executscalar (select referralcode from refer …
if (referralcode) can be saved in the table if nothing can not be saved? what approach the server event can use
thx

You may use the Form_CustomValidate server event (refer to the topic Server Events and Client Scripts → Form_CustomValidate in the help file).