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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validator

Status
Not open for further replies.

oenablx

Technical User
Feb 2, 2010
13
US
Hello
I currently have 4 radio buttons and one that validates a textbox.
This a way all 4 radio buttons validate the textbox?

Here is my code:

<html>
<head>
<title>RBtn Text Display</title>
<script type="text/javascript">
function Validate() {
if ((document.getElementById('choiceText').checked) && (document.getElementById('othertext').value == ''))
{
alert('Response required');
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="javascript:alert('Success')" onsubmit="return Validate()">
<input name="choice" type="radio" value="one" />Choice One<br />
<input name="choice" type="radio" value="two" />Choice Two<br />
<input name="choice" type="radio" value="three" />Choice Three<br />
<input name="choice" type="radio" value="four" />Choice Four<br />
<input name="choice" id="choiceText" type="radio" value="other" />Other<br />
<input type="text" name="othertext" id="othertext" /><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Customer Services Call Center,
Call Center Services,
IVR, Database Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top