Solved

Error Handling with Radio Buttons

Posted on 2006-10-19
10
139 Views
Last Modified: 2013-12-24
I have a form that asks 8 questiosns. After each question is a yes and a no radio button.

Each radio button is required.

If the user selects Yes for any of the questiosns, he or she must give information in a text box below concerning why he or she answered yes.

My question is:

1. How can I show the user in a pop up box (Like the ones the user recieves when he inputs a wrong character or wrong sysntax for a text box) that he or she needs to enter a explaination when a Yes is clicked.

I am already using Validation for all my text boxs (ie. phone, email etc). I would like to stay with that type of pop up message, instead of showing the message on another screen.


Thank you
0
Comment
Question by:linder76
  • 5
  • 5
10 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 250 total points
ID: 17767973

 Pop-ups (even javascript ones) give a poor user experience.   I understand your wanting to be consitent, but if this is not an error and simply information, do not give them a pop-up just to tell them they need to enter information.   Save the alert if they fail to enter the field when clicking submit..   Avoid using it in advance of a problem, the user would quickly become annoyed.

 The following will make the text field appear on the screen if YES is checked.  Along with it, a little message "Please Explain."   I think it would be enough simply to enable and disable the Please explain field, but you wanted a message so I am doing the magical appearing block which will get the users to notice..


 <script type="text/javascript">
   function hide(id) {
   document.getElementById(id).style.visibility = "hidden";
   };

   function show(id) {
   document.getElementById(id).style.visibility = "visible";
   };
 </script>


  <input type="checkbox"  onClick="if (this.checked ) hide('Q7')"> No

  <input type="checkbox"  onClick="if (this.checked) show('Q7')"> Yes

  <div id="Q7" style="visibility:hidden">
    Please Explain<br>
    <input type="text" name="Q7explain" size=50>
  </div>
0
 

Author Comment

by:linder76
ID: 17768351
This is an error.

What needs to happen is that once the user press "Continue" the code already goes through and gives pop up errors to the text boxs that do not meet the validation requirements.
I would like that to happen to, within the same pop up window, if possible so the user sees all the errors he or she needs to correct.

Thank you,
Joe
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17769025

 so then you just need to know if the checkbox is checked before checking if the corresonding text field is filled?

 something like this... ?

 if (document.getElementById('Q7Checkbox').checked && 
     document.getElementById('Q7textField').value = '') { alert('please fill out Q7') }

0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

Author Comment

by:linder76
ID: 17769073
Yes I also need to check if the text box has something in it...the text box is called explaination..


If I was writing in VBA it would go something like:


If C1='yes' then
 If explaination = "" then

 mgsbox "If you selected yes to any questions, please give an explaination in the text box below"
end if
end if

Also where would I put this code?
0
 

Author Comment

by:linder76
ID: 17769139
See what I am trying to do is...

Once the continue button is checked....

The text boxes are checked ...and if they are not filled in correctly a error pops up - that is working fine
Second, now the radio buttons need to be checked to see if any are yes if there are any that have yes then the explaination text box needs to be checked. If there is nothing in the text box, that is when  message needs to come up, or be part of the other other error text box

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17769343

 Ok, maybe I don't know what you are referring to by a "pop-up" box.  
  I thought you were referring to a javascript alert window.


>> I am already using Validation for all my text boxs (ie. phone, email etc).

   What language are you using to check all the fields you already have?  

0
 

Author Comment

by:linder76
ID: 17769365
yes sorry, in CF for inputboxes there is a validation setion..if the user violates the validation a "pop box" shows the user the error...it is not java script it is a built in function...
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17769583

 Ok, very easy then, its all coldfusion

 <cfif IsDefined('form.C1') and form.C1 is 'Yes' and len(form.explaination) eq 0>
     
  ... do whatever you do to add a message to this message box ....

 </cfif>


  This assumes that the name of the checkbox is C1.   If a checkbox is not checked the form variable will not exist, so you need to make sure its defined.  Len(  )  checks the number of characters in the variable,  if it returns 0, the field is empty...

   I don't know how you're creating or populating this "pop-up" box... but add to it in the <CFIF....


0
 

Author Comment

by:linder76
ID: 17769647
Sorry for the confusion

The pop up box is coming from this code

Inputbox type = "text"
.
.
.
.
Validate = "integer"
Message ="Please only enter integers"

Now once the user presses "continue" (the submit button) if the user for example puts a letter in this text box..that is when a pop up box comes up and says the message.

I hope this helps
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17770086

 The block you provided doesn't give any indication of the language or how its called, its not "native" coldfusion.

 If its coldfusion,  such as a custom tag.. then just call it between the CFIF statements I provided..

 It would look something like this...

<cf_Inputbox type = "text"
       Validate = "integer"
        Message ="Please only enter integers">



 Perhaps you can paste in a block of your code.  
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php.ini on ipage hosting 12 62
WSUS Client Issues 52 1,981
Systems talking to each other 5 141
How to fix Redundant Hostnames notification from google analytic? 5 45
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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…

839 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