日期:2014-05-18  浏览次数:20586 次

js问题
我   弄了   文本域   代码如下   :  

  <tr> <td   width= "100px "   align= "right "> 维护说明: </td> <td   align= "left "> <textarea   name= "profile "   rows= "4 "   cols= "20 "> </textarea> </td> </tr>

现在想写一个JS来使它为必填项,不填则跳出提示。但示了下发现他跟 <tr> <td   width= "100px "   align= "right "> 维护费用: </td> <td   align= "left "> <input   type= "text "   name= "maintainfare "> </td> </tr>   这种不同  
怎么写?

------解决方案--------------------
<%@ page language= "java " import= "java.util.* " pageEncoding= "GBK "%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> bottom </title>
<script language= "javascript ">
function checkForm(form)
{
var p = form.profile.value;

if(p== " ")
{
alert( "维护说明为空! ");
form.profile.focus();
return false;
}
}
</script>
</head>
<body>
<table>
<tr>
<td width= "100px " align= "right ">
维护说明:
</td>
<td align= "left ">
<form action= " " method= "post ">
<textarea name= "profile " rows= "4 " cols= "20 "> </textarea>
<input type= "submit " value= "提交 " onclick= "return checkForm(this.form); " />
</form>
</td>
</tr>
</table>
</body>
</html>