close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Unique Validation triggers error if field is left blank

Thread began 4/19/2012 11:32 am by Ian S | Last modified 4/20/2012 1:22 pm by Ian S | 563 views | 4 replies

Ian S

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

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...