codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Require text if checkbox checked  Archive Import (Kevin) at 15:46 on Monday, May 05, 2003
 

Any help with this is greatly appreciated: I need it to require text be entered into the textbox (name=Additional_Info) if the checkbox (name=Problem value=Other) is checked. I keep getting errors and don`t know what is causing the hang up. If you would like to see how the whole page works go to http://www.wattscopy.com/services/service_new.htm

Below is my script so far:

<script language="javascript">
<!--
function CheckForm() {
// require at least one checkbox be selected
var checkboxSelected = false;
for (i = 0; i < Service.Problem.length; i++)
{
if (Service.Problem.checked)
checkboxSelected = true;
}
if (!checkboxSelected)
{
// require text if "Other" checkbox checked
alert("Please select a checkbox to describe the problem you are
experiencing. If your issue is not listed please check \"Other\" and
describe in the text box.");
return (false);
}
if (document.Service.Problem.value == "Other") {
if (isempty(Additional_Info.value)) {
alert("Please enter your comments here.");
document.Service.Additional_Info.focus();
}
}
//-->
</script>

Kevin

  Re: Require text if checkbox checked  Archive Import (radek) at 10:29 on Tuesday, August 12, 2003
 

>for (i = 0; i < Service.Problem.length; i++)
>{
>if (Service.Problem.checked)

try
if (Service.Problem.checked)

  Re: Require text if checkbox checked  Archive Import (radek) at 10:30 on Tuesday, August 12, 2003
 

the square brackets are missing :/

if (Service.Problem`square bracket left`i`square bracket right`.checked)









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: onload event
•  Active Widgets
•  Re: onmouseover change image and text
•  Line Printer Interface
•  import contacts of msn/yahoo
•  Call windows apps from web apps
•  Re: ASP.NET web controls
•  netscape 6 browser problem
•  Re: Print .doc file from the website using System.Diagnostics.Process


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005