提交表单时我的代码有问题。如果在文本框中没有输入任何内容,则会出现正确的错误,但是当有无线电按钮响应的有效条目时,它仍然会显示一个错误,说“请选择一个分数”,例如选择分数时。
我似乎看不到我输入的错误。
一切顺利
CP
<form name="promoForm2" method=post enctype=multipart/form-data action=reactsubmit.php onSubmit="return validateForm();">
<ul class=mainForm id="mainForm_1">
<SCRIPT type=text/javascript>
function validateForm()
{
var x=document.forms["promoForm2"]["DJcomment"].value;
if (x==null || x=="")
{
alert("Please enter a comment.");
return false;
}
var x=document.forms["promoForm2"]["score"].value;
if (x==null || x=="")
{
alert("Please enter a score for the track.");
return false;
}
var x=document.forms["promoForm2"]["FavMix"].value;
if (x==null || x=="")
{
alert("Please select your favourite mix.");
return false;
}
}
</SCRIPT>
<table border='0'><tr><td>Support: </td><td><input type="radio" name="DJsupport" value="Yes">Yes<input type="radio" name="DJsupport" value="No">No</td></tr>
<tr><td>Favourite Mix: </td><td><input type="radio" name="FavMix" value="Enemy (Original Mix)">Enemy (Original Mix)</td></tr>
<tr><td></td><td><input type="radio" name="FavMix" value="Enemy (Original Mix)">Enemy (Original Mix)</td></tr>
<tr><td></td></tr><tr><td>Score: </td><td><input type="radio" name="score" value="1">1<input type="radio" name="score" value="2">2<input type="radio" name="score" value="3">3<input type="radio" name="score" value="4">4<input type="radio" name="score" value="5">5<input type="radio" name="score" value="6">6<input type="radio" name="score" value="7">7<input type="radio" name="score" value="8">8<input type="radio" name="score" value="9">9<input type="radio" name="score" value="10">10<td></tr><tr><td>Comment: (Required) </td><td><textarea name="DJcomment" rows="5" cols="40"></textarea></td></tr>
<tr><td></td><td><p class="mainForm"><input id="saveForm" class="mainForm" type="submit" value="Submit Reaction" /></td></tr></li></form>
</html>