js代码:
window.οnlοad=function(){
var text = document.getElementsByTagName('input');
var textvalue = text.value;
var label=document.getElementsByTagName('label');
var content=document.getElementById('content');
var button=document.getElementById('btn');
button.οnclick=function(){
for(i=0;i<5;i++){
if(text[i].value==''){
alert('请输入'+label[i-3].innerHTML);
text[i].focus();
return false;
}
}
if(content.value.length == 0 || content.value == ""){
alert('请输入反馈内容');
content.focus();
return false;
}
/* if (form1.head.value.length == 0 || form1.head.value == "") {
alert("请输入主题!");
form1.head.focus();
return false;
}
if (form1.user_name.value.length == 0 || form1.user_name.value == "") {
alert("请输入姓名!");
form1.user_name.focus();
return false;
}
if (form1.phone.value.length == 0 && form1.phone.value == "" && form1.qq.value.length == 0 && form1.qq.value == "") {
alert("请输入联系方式!");
form1.phone.focus();
return false;
}
if (form1.content.value.length == 0 || form1.content.value == "") {
alert("请输入反馈内容!");
form1.content.focus();
return false;
}
*/
}
}
html代码:
<table>
<tr><td align="center">反馈类型</td><td><input type="radio" name="type" checked="checked" />咨询 <input type="radio" name="type" />建议 <input type="radio" name="type" />投诉</td></tr>
<tr><td align="center"><label>反馈主题</label></td><td><input type="text" name="head" height="24" size="25" /></td></tr>
<tr><td align="center"><label>您的姓名</label></td><td><input type="text" name="user_name" size="25" /></td></tr>
<tr><td align="center"><label>联系电话</label></td><td><input type="text" name="phone" size="25" /></td></tr>
<tr><td align="center"><label>联系QQ</label></td><td><input type="text" name="qq" size="25" /></td></tr>
<tr><td align="center">反馈内容</td><td colspan="3"><textarea rows="7" cols="50" id="content"></textarea></td></tr>
<tr><td align="center"align="center"><td height="90" width="50" align="center"><input id="btn" type="button" name="commit" style="width:100px; height:24px;" value="提交" /></td><!--<td><input type="button" name="reset" style="width:100px; height:24px;" value="重置" />--></td></tr>
</table>