hi...anyone got ideas in form validation...I try a lot of methods already but still can't work...do not have any pop-up message although the required fill leave blank...is it the reason that I create my form in separate file??anyone got ideas on how to solve this problem?thanks in advance...
part of the code
class_survey.ph p
surveyForm.php
below are the source code (radio button) for the document in the browser...
for the score (textbox) and remark (textarea) also same like rating...array. ..any ideas???
part of the code
class_survey.ph p
Code:
while($row = mysql_fetch_array($result))
{
echo "<td width='50' align='center'>$row[no]</td>";
echo "<td width='500' align='left'>$row[question]</td>";
echo "<td align='center' width='500'>
<input type='radio' name='rating[$i]' value='1'/>1
<input type='radio' name='rating[$i]' value='2'/>2
<input type='radio' name='rating[$i]' value='3'/>3
<input type='radio' name='rating[$i]' value='4'/>4
<input type='radio' name='rating[$i]' value='5'/>5</td>";
echo "<td align='center' width='50'><input name='score[$i]' type='text' id='title'size='5' align='middle'></td>"
echo "<td><textarea name='remark[$i]' cols='25' id='title'></textarea></td>";
echo "</tr>";
$i++;
}
Code:
function validate()
{
if((document.surveyForm.rating[1].checked==false)&& document.surveyForm.rating[2].checked==false)&&(document.surveyForm.rating[3].checked==false))&&(document.surveyForm.rating[4].checked==false) &&(document.surveyForm.rating[5].checked==false&&(document.surveyForm.rating[6].checked==false)&&(document.surveyForm.rating[7].checked==false))
{
alert('Please choose the rating!');
return false
}
else if (surveyForm.score.value == "")
{
alert("Please insert mark.");
surveyForm.score.focus();
return false;
}
else if(surveyForm.remark.value == "")
{
alert("Please insert remark.");
surveyForm.remark.focus();
return false;
}
return true;
}
<form name="surveyForm" id="surveyForm" method="post" action="surveyForm2.php" onSubmit="return validate()">
<div align="center"><?php $survey->survey($form); ?></div>
</form>
Code:
<input type='radio' name='rating[1]' value='1'/>1<input type='radio' name='rating[1]' value='2'/>2<input type='radio' name='rating[1]' value='3'/>3<input type='radio' name='rating[1]' value='4'/>4<input type='radio' name='rating[1]' value='5'/>5 <input type='radio' name='rating[2]' value='1'/>1<input type='radio' name='rating[2]' value='2'/>2<input type='radio' name='rating[2]' value='3'/>3<input type='radio' name='rating[2]' value='4'/>4<input type='radio' name='rating[2]' value='5'/>5 repeat until ... <input type='radio' name='rating[7]' value='1'/>1<input type='radio' name='rating[7]' value='2'/>2<input type='radio' name='rating[7]' value='3'/>3<input type='radio' name='rating[7]' value='4'/>4<input type='radio' name='rating[7]' value='5'/>5<input type='radio' name='rating[1]' value='1'/>1 <input type='radio' name='rating[1]' value='2'/>2 <input type='radio' name='rating[1]' value='3'/>3 <input type='radio' name='rating[1]' value='4'/>4 <input type='radio' name='rating[1]' value='5'/>5 <input type='radio' name='rating[2]' value='1'/>1 <input type='radio' name='rating[2]' value='2'/>2 <input type='radio' name='rating[2]' value='3'/>3 <input type='radio' name='rating[2]' value='4'/>4 <input type='radio' name='rating[2]' value='5'/>5 repeat until ... <input type='radio' name='rating[7]' value='1'/>1 <input type='radio' name='rating[7]' value='2'/>2 <input type='radio' name='rating[7]' value='3'/>3 <input type='radio' name='rating[7]' value='4'/>4 <input type='radio' name='rating[7]' value='5'/>5
Comment