Click to See Complete Forum and Search --> : Who can help? very urgent!!!!


blackeel
12-12-2003, 11:01 PM
HI, everybody:

Below is my code. but it can not reach this requirement(if the user chooses"other"as their region then they must enter region in the text box, otherwise they should leave this text box blank.)
who can kindly help me to see where should i modify?

<html>
<head>
<title>
ITProducts.
</title>
<script language="javascript" tpye="text/javascript">
<!--
function checkform()
{
var name=document.ITProducts.name.value;
var foundAt=document.ITProducts.email.value.indexOf("@",0);


if(name=="")
{
alert("name is empty, please enter your name");
document.ITProducts.name.focus();
return false;
}

if (foundAt < 1)
{
alert ("your email address is not correct, check it!");
document.ITProducts.email.focus();
return false;
}


if (ITProducts.occupation.selectedIndex == 0)
{
alert("your must chose one kind of occupation!");
return false;
}

if(ITProducts.region0.value=="other")
{

if (document.ITProducts.other.value=="")
{
alert("please to fill in this cell");
document.ITProducts.other.focus();
return false;
}
return false;
}



return true;
}

//-->
</script>

</head>

<body>ITProducts.Com Registration Page
<form name="ITProducts" method="POST" action="http://localhost:8080/itc557/servlet/test" onSubmit="return checkform();">

<p>Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<input type="text" name="name" size="20"><br>
<br>

Email address:<input type="text" name="email"><br>
<br>


Occupation:<select name="occupation">
<option value="Choose your occupation">Choose your occupation</option>
<option value="Programmer">Programmer</option>
<option value="Network administrator">Network administrator</option>
<option value="Web developer">Web developer</option>
<option value="IT Manager">IT Manager</option>
<option value="Other">Other</option>
</select>
<br>


<br>Region:<br>
<INPUT TYPE="radio" Name="region" value="North America" CHECKED>North America<BR>
<INPUT TYPE="radio" Name="region" value="Asia">Asia <BR>
<INPUT TYPE="radio" Name="region" value="europe">Europe<BR>
<INPUT TYPE="radio" Name="region0" value="other">Other,
please specify:
<input type="text" name="other" ><BR>


<BR><INPUT TYPE=checkbox Name="check1" Value="Y">Subscribe to new products email list:
<BR><INPUT TYPE=checkbox Name="check2" Value="Y">Subscribe to special offers email list:<br>


<br><input type="submit" name="summit" value="submit"><input type=submit name="Reset" value="Reset">

</p>

</body>


</html>:rolleyes:

Khalid Ali
12-12-2003, 11:22 PM
try the following link,IT should point you in right direction

Resource Link (http://www.webapplikations.com/pages/html_js/forms/ForceInputCheckboxSelected.html)