I combine vote and login in the same form. Well first I have to validate user input(with javascript) so that it doesn't error in further proses. If the user doesn't fill choice option and select vote button then it will prompt "You haven't choose yet" , and if the user doesn't fill the ID and PIN text then it will promp error message.The problem is I don't know how to over come this problem.
Any idea?
Thanks!
<html>
<head>
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
function cek()
{
var msg="",ch=false;
msg="";
if (form1.Submit.value=="Vote")
{
for(a=0;a<3;a++)
{
msg="You haven't choose yet";
if (form1.r[a].checked==true)
{
ch=true;
msg="";
break;
}
}
}
else
{
if(form1.ID.value=="" || form1.PIN.value=="")
{
msg= "fullfulied ID and PIN to login first";
ch=false;
}
else
ch=true;
}
if (ch==true)
return true;
else
{alert (msg);
return false;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="select.php" onSubmit="return cek()">
<table width="88%" border="0">
<tr>
<td>What Is Your Hobby?</td>
<td colspan="3" rowspan="6"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="23%"><input type="radio" name="r" value="radiobutton">
Swimming</td>
<td width="23%"> </td>
<td width="33%"> </td>
</tr>
<tr>
<td><input type="radio" name="r" value="radiobutton">
Watching TV</td>
<td>ID</td>
<td><input name="ID" type="text" id="ID"></td>
</tr>
<tr>
<td><input type="radio" name="r" value="radiobutton">
Game</td>
<td>PIN</td>
<td><input name="PIN" type="password" id="PIN"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Vote"></td>
<td> </td>
<td><input name="Submit" type="submit" id="Submit" value="Login"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
</table>
</form>
</body>
</html>