rww
|
| Posted: 05/03/2003, 7:03 PM |
|
For CodeChargeStudio
I added an Add Code on OnValidate->Valdate Email for a form and it works. It reports the error if I don't put in a valid email addr and DOESN'T add the row in the table.
However, if I also add custom code that in the same event, doing basically the same thing, it doesn't work.
This works:
//Validate Email @18-9A0702F7
global $hash_paypal_join;
if (strlen($hash_paypal_join->admin_email->GetText()) && !preg_match("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $hash_paypal_join->admin_email->GetText()))
{
$hash_paypal_join->admin_email->Errors->addError("Stupid!!");
}
//End Validate Email
This reports "Stupid" on the form if an invalid email is put into the form and it doesn't add the record.
But this doesn't (it adds the row even if there's an error)...
//Custom Code @17-2A29BDB7
// -------------------------
// Write your own code here.
// -------------------------
global $DBtAccounts;
$sql="SELECT login FROM acct_members WHERE login=" . $DBtAccounts->ToSQL($hash_paypal_join->login->GetText(), ccsText);
$DBtAccounts->query($sql);
$xResult = $DBtAccounts->next_record();
if($xResult)
{
$hash_paypal_join->login->Errors->addError("Duplicate Login");
}
//End Custom Code
If a row exists with a duplicate login, I get the message "Duplicate Login", but it still adds the row, WHY?
P.S. This is all in the same function.
Thanks for any help anyone can provide!
|
|
|
 |
rww
|
| Posted: 05/03/2003, 8:32 PM |
|
Actually, I was wrong. Validate Email doesn't work either...
I took out the field property for Input Validation "EMail", but kept in the Action Code of Validation Email and it doesn't matter where I put it. It doesn't work.
I put it in OnValidate, Before Insert, Before Build Insert and Before Execute Insert of the form and although it reports the {Error} on the form, it still adds the row to the table.
What do I need to add that will prevent a row from being added if there is an error?
|
|
|
 |
rww
|
| Posted: 05/03/2003, 8:44 PM |
|
Never mind... I put the custom code on the field property of OnValidate and it works. Sorry to bother anyone!!
|
|
|
 |
|