close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to handle validation on a combined Radio buttons and Textarea question?

Thread began 12/05/2018 12:25 pm by Nathon Jones Web Design | Last modified 12/06/2018 8:51 am by Ray Borduin | 1361 views | 8 replies |

Nathon Jones Web Design

How to handle validation on a combined Radio buttons and Textarea question?

I have a question with a Yes/No response. For example....

Any other comments Yes (value = 1) No (Value = 2)

Below this I have a textarea field. If the user selects Yes, I'd like validation to force them to complete the textarea.
What type of validation should I be selecting here? I couldn't see anything relevant.

I need to do the Validation If, and that needs to be based on the Radio button response, but I'm not clear what type of validation to run? Alphanumeric and only allow a 1 or 2?

Would appreciate your advice. Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Are you doing client jquery or server validation?

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

Nathon Jones Web Design

Neither as of yet, as I note you've advised Client jQuery in your other reply, although I had asked about customising the CSS as the speech bubbles aren't mobile compatible.

Would take your advice on which solution is best. I'd like the validation to be as robust as possible.

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Well server validation is the most solid, since javascript can be bypassed. Client validation is a better user experience and often simpler to implement since you don't have to submit the page. I usually will use both, but on sites that I'm not really worried about hacking and bad values entered maliciously (like admin back ends) then javascript validation is sufficient and you can skip server since it would never be used if the client validation works properly.

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

Nathon Jones Web Design

I'll use server validation on this particular project then as it's a public front-end submitting personal medical information.

Sign in to reply to this post

Ray BorduinWebAssist

In that case you can use Required validation on the server variable:

php:
<?php echo((isset($_POST["RadioName"]) && $_POST["RadioName"] === "1")?$_POST["TextAreaName"]:"pass"); ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

Sorry Ray, I'm using the Server Validations Insert wizard here.

My trigger is the pressing of the submit button, validation type is "Required" as you've stated, then I have to select a Server variable...is the code you've provided above what I insert in the "Code" option in the Choose Variable to Validate wizard window?

I've added that and uploaded it to the page but, relating to a post I'd added whilst you were away (when you couldn't get FTP access because of your location), it's not doing the second validation at all.

The secondary validation, healthscreeningform_476, has been applied to this page on a single field - the "Have you consulted your GP for any health related issues in the the past 3 years?" radio button question and the textarea below it in the GP section in Step 2.

Here's the link to the form again. The validation set up on Step 1 works, but any additional validations don't.
http://www.sportsmedicalcertificates.com/health-screening-form.php?tab1=1

Sign in to reply to this post

Nathon Jones Web Design

Just spotted that the WA Server Validation was inserting the first WA Server Validation title, healthscreeningform_984, in the validation for the second WA Server Validation, healthscreeningform_476.

I've updated that manually and both validation behaviours appear to be working now.

Still a couple of issues though...

I've had to append querystring data to the $WAFV_Redirect so that the correct Bootstrap tab is loaded upon validation failure, as follows:
$WAFV_Redirect = "health-screening-form.php?tab2=1&v=1";

The problem with this is that every time validation takes place it continues to add querystrings to the URL, like this (three validation attempts):
health-screening-form.php?tab2=1&v=1&tab2=1&v=1&tab2=1&v=1

Why isn't it just updating the querystrings, considering that they have the same name?

Sign in to reply to this post

Ray BorduinWebAssist

If you update the <form> tag action to action="health-screening-form.php" that should prevent the repeated parameters.

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

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