Unique Validation triggers error if field is left blank
Hi,
I am currently putting a page together with a couple of form fields on.
Both fields are required, and the first field needs to be unique.
<?php
if (isset($_POST["BT_Create"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_pluginnew_788_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["friendlyname"]))?$_POST["friendlyname"]:"") . "",true,1);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["filename"]))?$_POST["filename"]:"") . "",true,2);
$WAFV_Errors .= WAValidateUnique("webcatdb",$webcatdb,$database_webcatdb,"plugins","plugin_id","none,none,NULL","0","plugin_name","',none,''","".(((isset($_POST["friendlyname"]))?$_POST["friendlyname"]:"")) ."",true,3);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"pluginnew_788");
}
}
?>
I then have two error messages next to the friendlyname field. These are wrapped in Show If statements.
<?php
if (ValidatedField('pluginnew_788','pluginnew_788')) {
if ((strpos((",".ValidatedField("pluginnew_788","pluginnew_788").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="texterror">Please enter a friendly name for this plugin.</span>
<?php //WAFV_Conditional pluginnew.php pluginnew_788(1:)
}
}
}?>
<?php
if (ValidatedField('pluginnew_788','pluginnew_788')) {
if ((strpos((",".ValidatedField("pluginnew_788","pluginnew_788").","), "," . "3" . ",") !== false || "3" == "")) {
if (!(false)) {
?>
<span class="texterror">A plugin with this name already exists.
<?php //WAFV_Conditional pluginnew.php pluginnew_788(3:)
}
}
}?>
My problem seems to be that if the friendlyname field is left blank, the Unique validation error triggers and is shown aswell as the required error message.
Is there a way to stop the Unique validation error showing if the field is left blank, and only show the 'required' error?
Cheers
Ian