Validation duplicate field
Validation duplicate field
Allan
I've read the discussion https://datatables.net/forums/discussion/12650/check-for-duplicates/p1 to learn how to do it.
So I did
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
$res = $db->sql( ' SELECT COUNT(*) as count FROM empresas WHERE razsoc LIKE "'.$_POST['data']['razsoc'].'"');
$count = $res->fetch();
if($count !== 0){ return "Duplicate value";}
}
Should I add also validation function in the field ? ? What did I miss ?
Thanks a lot
I've read the discussion https://datatables.net/forums/discussion/12650/check-for-duplicates/p1 to learn how to do it.
So I did
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
$res = $db->sql( ' SELECT COUNT(*) as count FROM empresas WHERE razsoc LIKE "'.$_POST['data']['razsoc'].'"');
$count = $res->fetch();
if($count !== 0){ return "Duplicate value";}
}
Should I add also validation function in the field ? ? What did I miss ?
Thanks a lot
This discussion has been closed.
Replies
Just a warning for the user
You'll need to add something onto the JSON data that is being sent back to the client-side (rather than the return) and then use the onSubmitComplete function to check the JSON, and if that warning is present, use an alert().
Regards,
Allan