close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Form text field in repeated selection and server validation

Thread began 1/17/2018 8:34 am by tony | Last modified 1/19/2018 9:38 am by Ray Borduin | 2514 views | 15 replies |

tony

Form text field in repeated selection and server validation

Hello all,
I have a form with one text field.
I applied the "WA repeat selection" and I duplicate this field X times. Nice.
But all repeated fields have the same ID, so I changed their IDs using the counter from the bindings. It works.
Now I need to server validate them.
How can I server validate these repeating text fields?
TIA

tony

Sign in to reply to this post

Ray BorduinWebAssist

Client Validate is easier ;)

What type of validation do you want on them? Are they all required?

Sign in to reply to this post
Did this help? Tips are appreciated...

tony

yes,
but there is money involved (it's a cashback). So, I prefer using server validation, just in case someone disable javascript on his browser...
Thanks

tony

Sign in to reply to this post

Ray BorduinWebAssist

What type of validation? Required? Numeric?

Sign in to reply to this post
Did this help? Tips are appreciated...

tony

Sorry, my "yes" was for "all required".
They are text fields, basically.
Tony

Sign in to reply to this post

tony

my 2c.
What if I creater static fields, then apply the Wa server validation and then add the WA repeat selection to the text fields and the WA validation?
Of course I will need to tweak the code a bit.
But I just need to know if there are better ways to do this.
It would be nice to create something similar to this (https://bootsnipp.com/snippets/AXVrV) and then apply the WA logic.
Tony

Sign in to reply to this post

Ray BorduinWebAssist

If you always only have six then you can just add them manually one at a time to the server validation.

Another option is to write a loop to do it, but then you wouldn't be able to re-enter the server validation server behavior.

If you attach a copy of the page you are working on I can give you code samples for each.

Sign in to reply to this post
Did this help? Tips are appreciated...

tony

Thanks, Ray,
here is attached the step2.php page. Please keep in mind that in step1.php I set a session variable (numart_sess) that holds the number of copies I need to create about the fields Articolo and Barcode in step2. This is decided by the user in step 1 by using a dropdown menu (values range from 1 to 15 maximum).
So, basically, in step 2 I need to get maximum 15 Articolo fields and maximum 15 Barcode fields.
Then I need to validate all fields and save all fields values to session variables. In step3.php page I will display all collected data and save it to database (in a single record).
Thanks again, Ray.
Tony

Attached Files
step2.php
Sign in to reply to this post

Ray BorduinWebAssist

I'd just add a for loop around both the display and validation and add the increment.

Something like:

php:
<?php 

if (isset($_POST["next2"]) || isset($_POST["next2_x"]))  {
  
$WAFV_Redirect "step2.php";
  
$_SESSION['WAVT_step2_279_Errors'] = "";
  if (
$WAFV_Redirect == "")  {
    
$WAFV_Redirect $_SERVER["PHP_SELF"];
  }
  
$WAFV_Errors "";
for (
$x=1$x<=intval($_SESSION['numart_sess']); $x++) {
  
$WAFV_Errors .= WAValidateRQ(((isset($_POST["articolo_".$x  .""]))?$_POST["articolo".$x  .""]:"") . "",true,$x);
  
$WAFV_Errors .= WAValidateRQ(((isset($_POST["barcode_".$x  .""]))?$_POST["barcode".$x  .""]:"") . "",true,"2".$x);
}
  if (
$WAFV_Errors != "")  {
    
PostResult($WAFV_Redirect,$WAFV_Errors,"step2_279");
  }
}
?>



and then the display like:

php:
<?php

for ($x=1$x<=intval($_SESSION['numart_sess']); $x++) {
?>
        <div class="form-group">
                    <label for="articolo_<?php echo($x); ?>">Articolo <?php echo($x); ?></label>
                    <input name="articolo_<?php echo($x); ?>" type="text" class="form-control" id="articolo_<?php echo($x); ?>" placeholder="Articolo" value="<?php echo(WA_getSavedFormValue("persist_step2","articolo_".$x  ."")) ?>">
<?php
if (ValidatedField('step2_279','step2_279'))  {
  if ((
strpos((",".ValidatedField("step2_279","step2_279").","), "," "".$x  ."" ",") !== false || "1" == ""))  {
    if (!(
false))  {
?>
                            <div class="errore_validazione">errore articolo </div>
                            <?php //WAFV_Conditional step2.php step2_279(1:)
    
}
  }
}
?>
        </div>
        
        
        <div class="form-group">
                    <label for="barcode_<?php echo($x); ?>">barcode <?php echo($x); ?></label>
                    <input name="barcode_<?php echo($x); ?>" type="text" class="form-control" id="barcode_<?php echo($x); ?>" placeholder="barcode" value="<?php echo(WA_getSavedFormValue("persist_step2","barcode_".$x  .")) ?>">
                    
                        
                        
                            <?
php
if (ValidatedField('step2_279','step2_279'))  {
  if ((
strpos((",".ValidatedField("step2_279","step2_279").","), "," "2".$x  ."" ",") !== false || "2" == ""))  {
    if (!(
false))  {
?>
                                <div class="errore_validazione">errore barcode </div>
                                <?php //WAFV_Conditional step2.php step2_279(2:)
    
}
  }
}
?>
        </div>
<?php
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

tony

Just as information (see below):

Originally Said By: Ray Borduin
  
php:
[snip]

  if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "".$x  ."" . ",") !== false || "1" == ""))  {

[snip]
  if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "2".$x  ."" . ",") !== false || "2" == ""))  {
[snip]
  



But what are those numbers "...) !== false || "1" == "")) {..." and "...) !== false || "2" == "")) {..."?
Have I to change them to:

php:
if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "".$x  ."" . ",") !== false || "".$x."" == ""))  {

if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "2".$x  ."" . ",") !== false || "2".$x."" == ""))  {


Thanks
Tony

Sign in to reply to this post
loading

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