Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript error checking problem.

Status
Not open for further replies.

wu78754

Programmer
Nov 6, 2009
12
US
I copied an example from the web, but I can't get it to work.
Here is the code.

function CheckForm ()
{

// ** START **
if (document.ClientInfo.x_terms_conditions != "agreed") {
alert( "Please read the Terms and Conditions and agree to it." );
return false;
}
else
return true ;
// ** END **
}

<form name="ClientInfo" action=" method="POST" onsubmit="return CheckForm();">

<tr><td bgcolor="#f0f0f0" class="bodyTEXT2"><input type="radio" name="x_terms_conditions" value="agreed" />I have read and agreed to TicketEddy's Terms and Conditions.</td>
<td bgcolor="#f0f0f0" class="bodyTEXT2"><input type="radio" name="x_terms_conditions" value="declined" CHECKED />I do not agree to TicketEddy's Terms and Conditions.</td></tr>

Whether I click on "agreed" or "declined", I got the alert. If I change the != to ==, I don't get any alert, whether it's "agreed" or "declined." When I tried to print out x_terms_conditions, it says object nodelist.

Help!
 
Hi

Code:
[b]function[/b] [COLOR=darkgoldenrod]CheckForm[/color][teal]()[/teal]
[teal]{[/teal]
  [b]if[/b] [teal](![/teal]document[teal].[/teal]ClientInfo[teal].[/teal]x_terms_conditions[teal][[/teal][purple]0[/purple][teal]].[/teal]checked[teal])[/teal] [teal]{[/teal]
    [COLOR=darkgoldenrod]alert[/color][teal]([/teal] [green][i]"Please read the Terms and Conditions and agree to it."[/i][/green] [teal]);[/teal]
    [b]return[/b] [b]false[/b][teal];[/teal]
  [teal]}[/teal] [b]else[/b] [b]return[/b] [b]true[/b] [teal];[/teal]
[teal]}[/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top