Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 07-28-2009, 02:34 PM   #1 (permalink)
Registered User
 
Join Date: May 2008
Posts: 23
OS: XP


Conditional Form Requirements (ASP.NET)

Hey guys,

I'm trying to make a form that has a conditional form requirement, but I'll dumb it down for this purpose:

The form would ask a question like so:

Are you cool?

This would be followed by two radio buttons: Yes, and No.

If the user selects "Yes", I want the next text box to have to be filled out. If the user selects "No", they shouldn't need to fill out the next box.

Any ideas? I've looked into Compare validators and such, but have not found a solution. It shouldn't be too hard to figure out, the trick is doing it on the client side though, as I don't want to use Ajax to load any part of the page again.

Thanks!
pjb5064 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 07-29-2009, 05:12 AM   #2 (permalink)
God (TSF Enthusiast)
 
ahmorrow's Avatar
 
Join Date: May 2009
Location: Jeffersonville, IN
Posts: 905
OS: Ubuntu 9.10 [Karmic Koala]

My System

Send a message via AIM to ahmorrow Send a message via Yahoo to ahmorrow
Re: Conditional Form Requirements (ASP.NET)

Javascript. Let me know if this makes any sense to you.

Code:
<script type="text/javascript">
<!--
if (radioYes.value="selected") {
  if (textboxIfCool.value="") {
  window.alert("ERROR:  You must fill in such and such textbox."
  }
}
//-->
</script>
__________________
If I have not responded to a post in 24 hours or more, PM me with a link to the thread and I'll get back to you. I do not help via PM/IM/Email.
ahmorrow is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 07-30-2009, 08:34 AM   #3 (permalink)
Registered User
 
Join Date: May 2008
Posts: 23
OS: XP


Re: Conditional Form Requirements (ASP.NET)

thats great, but honestly the only problem is that I don't want a popup. The rest of my errors throw a red "*" next to the item, which I'm sure I can put a label and change the text with javascript as well?

You'll have to excuse my lack of knowledge with javascript, but if this is possible, let me know!

Thank you!
pjb5064 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 07-30-2009, 09:17 AM   #4 (permalink)
God (TSF Enthusiast)
 
ahmorrow's Avatar
 
Join Date: May 2009
Location: Jeffersonville, IN
Posts: 905
OS: Ubuntu 9.10 [Karmic Koala]

My System

Send a message via AIM to ahmorrow Send a message via Yahoo to ahmorrow
Re: Conditional Form Requirements (ASP.NET)

change
Code:
window.alert("ERROR:  You must fill in such and such textbox."
to
Code:
document.write(getElementById(pBeforeRadioYes.innerText="*"));
or something similar. If you don't get it still I'll rewrite it later.
__________________
If I have not responded to a post in 24 hours or more, PM me with a link to the thread and I'll get back to you. I do not help via PM/IM/Email.
ahmorrow is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 07:19 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85