close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

validations not working

Thread began 8/14/2012 11:58 am by JamieEff | Last modified 8/14/2012 2:23 pm by JamieEff | 1118 views | 8 replies |

JamieEff

validations not working

Hi Jason

On that page we were discussing on skype earlier, I have set up server validations as per this code: (also image1 attached)

php:
<?php 

if (isset($_POST["add"]) || isset($_POST["add_x"]))  {
  
$WAFV_Redirect "clientarea-update.php";
  
$_SESSION['WAVT_clientareaupdate_502_Errors'] = "";
  if (
$WAFV_Redirect == "")  {
    
$WAFV_Redirect $_SERVER["PHP_SELF"];
  }
  
$WAFV_Errors "";
  
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Item"]))?$_POST["Item"]:"") . "",false,1);
  
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Description"]))?$_POST["Description"]:"") . "",false,2);
  
$WAFV_Errors .= WAValidateNM(((isset($_POST["Cost"]))?$_POST["Cost"]:"") . "",0,100000,"",",.",true,3);

  if (
$WAFV_Errors != "")  {
    
PostResult($WAFV_Redirect,$WAFV_Errors,"clientareaupdate_502");
  }
}
?>



This works fine in redirecting the user to the page if one of the 3 fields is empty.

I then added 3 different validation show ifs (as per image 2, 3 and 4) with this code:

php:
<?php

if (ValidatedField('clientareaupdate_502','clientareaupdate_502'))  {
  if ((
strpos((",".ValidatedField("clientareaupdate_502","clientareaupdate_502").","), "," "1" ",") !== false || "1" == ""))  {
    if (!((
strpos((",".ValidatedField("clientareaupdate_502","clientareaupdate_502").","), "," "1" ",") !== false || "1" == "")))  {
?>
              <div style="clear:both;color:#F00;">Please enter a valid 'item' entry</div>
              <?php //WAFV_Conditional clientarea-update.php clientareaupdate_502(1:1)
    
}
  }
}
?>



Now the error statement does not show when you go to the page but non of them display if there is an error

I have tried god knows how many ways it could be, but I am lost as to what I have done wrong.

Many thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

dont set a validation pass condition, leave the validation pass condition blank, by setting the validation pass condition to the same as the validation fail condition, it is canceling the error out.

think of it this way:
there can never be an instance where the validation will both pass and fail. by setting the validation pass condition, you are canceling out the ability to display the message.

Sign in to reply to this post

JamieEff

thanks Jason

Thats working a treat now!

in the event that only 1 field fails, how would I get the 2 successful ones to retain the content that was initially attempted to be submitted so the user doesnt have to input it again?

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

in the bindings panel, expand the validated entries binding group.

bind the initial value of your form elements to the corresponding Validated entries biding.

Sign in to reply to this post

JamieEff

thanks Jason

Thats worked on 50% of the input fields but not on these 2:

php:
<textarea name="Item" rows="4" class="" id="Item" value="<?php echo(ValidatedField("clientareaupdate_502","Item")) ?>" style="float:left;width:248px;"></textarea>



php:
<textarea name="Description" rows="4" class="" id="Description" value="<?php echo(ValidatedField("clientareaupdate_502","Description")) ?>" style="float:left;width:248px;"></textarea>
Sign in to reply to this post

JamieEff

think I have have figured it out...

the binding needs to be surrounded by the <textarea></textarea> tags

ie:

php:
<textarea name="Item" rows="4" class="" id="Item" style="float:left;width:248px;"><?php echo(ValidatedField("clientareaupdate_502","Item")) ?></textarea>
Sign in to reply to this post

JamieEff

last question on this one

how would I do the same for the client field which is drawing data from the database - ie if one field fails the client selected in the drop down is remembered:

php:
<select name="Client" id="Client" style="float:left;width:255px;height:25px;">

                <?php
do {  
?>
                <option value="<?php echo $row_Clients['UserID']?>"><?php echo $row_Clients['UserFirstName']?></option>
                <?php
} while ($row_Clients mysql_fetch_assoc($Clients));
  
$rows mysql_num_rows($Clients);
  if(
$rows 0) {
      
mysql_data_seek($Clients0);
      
$row_Clients mysql_fetch_assoc($Clients);
  }
?>
              </select>
Sign in to reply to this post

Jason ByrnesWebAssist

click the select list in design view, in the property inspector, click the dynamic button, and bind the Select Value Equal To option to the corresponding binding from the validated entries binding group.

Sign in to reply to this post

JamieEff

thanks Jason

Sign in to reply to this post

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...