close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Validation conditionals possible?

Thread begun 4/28/2009 12:19 pm by eric341232 | Last modified 10/29/2014 9:08 am by Jason Byrnes | 7169 views | 11 replies |

eric341232

Validation conditionals possible?

It would be great to be able to set conditions for certain validation situations. I hope that's part of any upgrade in the future.

In the meantime, I wonder if there is any way to work conditions into scheme as is, and by conditional I mean that, for instance, a check in a "phone" checkbox would require that a phone number be entered in the phone field. A phone number would not be required if it is not checked. This sort of thing, if some form field condition is true, then some validation has to happen on some other form field, and this beyond simple comparison of what's been entered, although maybe that trigger could be jiggered.

You see what I'm getting at. Any thoughts on this?

Sign in to reply to this post

Ray BorduinWebAssist

You can already do it both client and server side.

Are you doing client or server validation? What server language?

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

eric341232

I'm using server side validation, the php variety. I don't see a conditional option. The only kind of conditional I see is "like entry."

It's certainly possible that setting up conditional validation where if, for instance, a checkbox is selected then a particular text input must have data, is available but I just don't see it.

I've got

Alphanumeric
CC number
Date/time
Email address
entry length
File extension
like entry
number
phone number
regular expression
required/not blank/selection made
restrict content
SS number
url
zip code

I must not be seeing something right in front of my face.

Sign in to reply to this post

Ray BorduinWebAssist

It takes a small amount of logic and scripting within the interface to pull off.

For instance... if you are using phone number validation on a field called phoneNumber and you only want it required if a checkbox called callMe is checked.

You would use phone number validation and for the validated value you would browse to the phoneNumber field in the bindings, which would give you the value:
<?php echo((isset($_POST['phoneNumber'])?$_POST['phoneNumber']:"")); ?>

Now update it to use:
<?php echo((isset($_POST['callMe'])?$_POST['phoneNumber']:"(222) 222-2222")); ?>

This tells it to check to see if callMe was checked and if it is send the value of phoneNumber to be validated, otherwise it passes a valid phone number which would pass validation. The end result is exactly what you want.

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

eric341232

Yes. Now that I see it, that seems right. Thank you.

Sign in to reply to this post

Miguel

can i do this but not with checkbox?

I have a form to upload 6 pictures example

Thumb
pic1
pic1 big
pic2
pic2 big etc.....

i only require the thumb pic1 and pic1 big until here im ok but i want that if the user uploads a pic2 that pic2 big becomes required if he doesnt select any file for pic 2 then theres no need for pic2 big, any help if this can be done?

Sign in to reply to this post

Ray BorduinWebAssist

Yes, this can be done with either client or server validation. Of course server validation is more secure since it can't be turned off.

You know if you use Digital File Pro you can have them only upload the big image and automatically create the thumb and get around the need for validation in this case as well.

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

Miguel

Came back to this post cause now im trying to do something similiar i have a check box field and some text field i only want them to be required if the checkbox is selected, i did the above explained by Ray Borduin, but it always ask me to check the checkbox in order to continue, im using server side validation wich is the one i prefer cause it cant be shut down.


php:
<?php 
if (isset($_POST["KT_Custom1"]))  {
  
$WAFV_Redirect "";
  
$_SESSION['WAVT_depositar_716_Errors'] = "";
  if (
$WAFV_Redirect == "")  {
    
$WAFV_Redirect $_SERVER["PHP_SELF"];
  }
  
$WAFV_Errors "";
  
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Tipo_de_operacion"]))?$_POST["Banco_seleccionado"]:"") . "",false,2);

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

form elemnts:

<label for="Tipo_de_operacion">Already made deposit:
<input type="checkbox" name="Tipo_de_operacion" id="Tipo_de_operacion" value="1" />
</label>

<label for="Banco_seleccionado">Type your deposit number:
<input type="text" name="Banco_seleccionado" id="Banco_seleccionado" value="" size="32" /></label>

And the show if

php:
<?php
if (ValidatedField('depositar_716','depositar_716'))  {
  if ((
strpos((",".ValidatedField("depositar_716","depositar_716").","), "," "2" ",") !== false || "2" == ""))  {
    if (!(
false))  {
?>
            Requiered field
  <?php //WAFV_Conditional depositar.php depositar_716(2:)
    
}
  }
}



?>



this checkbox internally is called "Tipo_de_operacion" the label out side is diffrent i want the user that if he is going to pay with a bank deposit he has to fill in a textfield with the deposit number, if he doesnt select the check box it should continue to insert the form to save the order for later payment.

I had no luck with the above technic to tell on server side validation that only if the checkbox is selected, what am i doing wrong here cause if i select the checkbox and fill the text field it works but thats not the point or goal to make this work,

Can we get a better example on how is it done with server side includes?

Thanks
Sades

Sign in to reply to this post

Ray BorduinWebAssist

change:

:""

to

:"1"

That is the value to validate when the checkbox is not checked, if you set it to a non-blank value it will pass validation when the checkbox is not checked automatically.

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

Miguel

thank you worked nice

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