Solved

Required fields validation

Posted on 2006-11-21
10
150 Views
Last Modified: 2013-12-24
I have a question, on my form, I have a few field that are required is the user is going to register as a paid member.
But I have a radio button where the user selects paid member, or free member. Where if free member is selected I hide
a few fields. But since I'm using the coldfusion required field I would like to know if there is a way to set the required field to NO when the free radio button is selected.

I created this JS but doesn't seen to work.

      document.getElementById("buyerZipCode").required ='no';

any idea?
0
Comment
Question by:Ennio
10 Comments
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17990344
i always (well so i have learnt on here from others) to use script to validate, it will give you more control for example...


<cfif Len(#FORM.example#) LT x>
  <script>
      alert('you need to enter a number! etc.)
      history.go(-1)
      </script>
  <cfabort>
<cfif/>

0
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17990380
PS,

quote > I created this JS but doesn't seen to work.

it won't, the page has already been served by this point i think, the page would need to be refreshed
0
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17990421
in you're case i would check input on submit if the users has picked paid or free (cfif isdefined etc), if paid is picked check the fields you need to be filled in have got the correct values, if not display a message like in the example above and take them back a page "history.go(-1)"
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 20

Accepted Solution

by:
trailblazzyr55 earned 500 total points
ID: 17990818
In this case it sounds like you should do away with the <cfinput> and built in validation and just use javascript validation, this way you have a lot more control over what's going on...

if you post the code we can help modify it to do what you need...
0
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17990957
i knew you were going to say that trailblazzyr55, helping me sooooooooo many times you finally drummed that into me lol.

I only decided to try and answer a few questions in CF based on what I have learnt/remembered from the last few questions you answered for me, hope you don’t mind its all in the learning curve.

0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17991130
Nah, I encourage you to answer questions to help others learning or to solve problems you might have answers to. Experts may debate over questions but in the end it serves to help those asking questions... I don't know everything there is to know about CF, but answering questions and being corrected sometimes helps as much as asking questions... ;o)
0
 
LVL 1

Author Comment

by:Ennio
ID: 17991142
I created my own JS, it gives you more flexibility

Now I can manage what I need to be the required fields.
0
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17991166
cool, thanks trailblazzyr55 thats goodto know, anyway  Ennio sorry to highjack the post, back to the question :)

0
 
LVL 12

Expert Comment

by:pigmentarts
ID: 17994065
> I created my own JS, it gives you more flexibility

thats what trailblazzyr55 stated to do, what JS did you use?
0
 
LVL 1

Expert Comment

by:CutterBl
ID: 18112834
Try using jQuery simple Form Validation

http://www.willjessup.com/?p=9
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Time Sheet Help 6 54
remove Handler and Add Handler for one file 3 44
Recipient address rejected: User unknown in virtual alias table 1 290
Domino Website - Redirection 12 74
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question