close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

how to validate a field on condition?

Thread began 7/07/2016 1:31 am by tony | Last modified 7/07/2016 7:22 pm by Ray Borduin | 1028 views | 5 replies |

tony

how to validate a field on condition?

Hi all,
I have a form with a dropdown menu and a text field.
The text field is disabled until I select a specific value from the dropdown menu.
When I select the right value in the dropdown menu, the text field gets enabled (I used jquery to handle enable/disable) and I need to validate it.
If it's disabled I don't have to validate it.
How can I validate the text field only if it's enabled?
TIA
tony

Sign in to reply to this post

Ray BorduinWebAssist

Are you doing client or server validation for the rest of the form?

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

tony

Originally Said By: Ray Borduin
  Are you doing client or server validation for the rest of the form?  


I'm doing server side validation.
TIA
tony

Sign in to reply to this post

Ray BorduinWebAssist

In your validation you can use something like: <?php echo($_POST['selectfieldname']=="other")?$_POST['textfieldname']:"n/a"; ?>

That way if the value of the select field is "other" it will validate the text field, but if it isn't it will use "n/a" which would pass validation.

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

tony

Originally Said By: Ray Borduin
  In your validation you can use something like: <?php echo($_POST['selectfieldname']=="other")?$_POST['textfieldname']:"n/a"; ?>

That way if the value of the select field is "other" it will validate the text field, but if it isn't it will use "n/a" which would pass validation.  


Hi Ray,
thanks for your patience,
where should I put this code?
what kind of validation should I select from the "validation type" list?
TIA
tony

Sign in to reply to this post

Ray BorduinWebAssist

As the validated value. I was thinking you were needing required validation.

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