用js来判断输入框是否为空!和返回到上一个页面!

<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>药品修改</title>
<link href="${pageContext.request.contextPath}/ui/css/style_cn.css" rel="stylesheet" type="text/css">

<!-- 判断药品信息,名称,适应症,用法用量,生产日期,有效期--有些不能为空! -->
<SCRIPT type="text/javascript">
function checkSubmit(){
var cname = form1.cname.value;
var indication = form1.indication.value;
var udosage = form1.udosage.value;
var date = form1.date.value;
var limits = form1.limits.value;
if(cname!=0){
if(indication!=0){
if(udosage!=0){
if(date!=0){
if(limits!=0){
document.forms[0].submit();
}else{
alert("有效期不能为空!");
}
}else{
alert("生产日期不能为空!");
}
}else{
alert("用法用量不能为空!")
}
}else{
alert("适应症不能为空!");
}
}else{
alert("药品名称不能为空!")
}
}
</SCRIPT>
</head>

<body>
<s:form name="form1" method="post" action="drugsAction_update.do" namespace="/sys">
<s:hidden name="id"/>
<div class="mtitle">
<div class="mtitle-row">&nbsp;</div>
药品修改
</div>
<br>
<div class="control">
<button type='button' class='button' onMouseOver="this.className='button_over';" 
       onMouseOut="this.className='button';"  onClick="checkSubmit(this.form)">
       <img src="${pageContext.request.contextPath}/ui/images/button/baocun.png" border='0' 
            align='absmiddle'>&nbsp;保存</button>
<button type='button' class='button' onMouseOver="this.className='button_over';" 
       onMouseOut="this.className='button';"  onClick="window.history.go(-1)">
       <img src="${pageContext.request.contextPath}/ui/images/button/fanhui.png" border='0' 
            align='absmiddle'>&nbsp;返回</button>
</div>
<table width="100%" border="0" cellspacing="0" class="tabForm">
  <tr>
    <th colspan="4" align="left" class="th_head">
<div id="menuArrow1" style="background:url(${pageContext.request.contextPath}/ui/images/down.gif) no-repeat center;float:left;">&nbsp;</div>
<div id="menuTitle1" style="font-weight:bold">基本信息</div>
</th>
  </tr>
  <tr>
  <td>
<div id="menu1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="16%"></td>
<td width="34%"></td>
<td width="16%"></td>
<td width="34%"></td>
</tr>
<tr>
<td class="red">药品名称:</td>
<td>
<s:textfield name="cname" cssClass="input" cssStyle="width:90%"/>
</td>
<td>英文名称:</td>
<td>
<s:textfield name="ename" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>
<tr>
<td>剂型:</td>
<td>
<s:textfield name="dosage" cssClass="input" cssStyle="width:90%"/>
</td>
<td>规格:</td>
<td>
<s:textfield name="specification" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>
<tr>
<td>成份:</td>
<td>
<s:textfield name="ingredients" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>
<tr>
<td height="40" valign="top">适应症:</td>
<td colspan="3">
<s:textarea name="indication" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">用法用量:</td>
<td colspan="3">
<s:textarea name="udosage" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">不良反应:</td>
<td colspan="3">
<s:textarea name="effect" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">禁忌:</td>
<td colspan="3">
<s:textarea name="taboo" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">注意事项:</td>
<td colspan="3">
<s:textarea name="attention" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">特殊人群用药:</td>
<td colspan="3">
<s:textarea name="special" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">药物相互作用:</td>
<td colspan="3">
<s:textarea name="druginteraction" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td height="40" valign="top">药理作用:</td>
<td colspan="3">
<s:textarea name="pharmacological" rows="3" cssStyle="width:96%"></s:textarea>
</td>
</tr>
<tr>
<td>贮藏:</td>
<td>
<s:textfield name="storage" cssClass="input" cssStyle="width:90%"/>
</td>
<td>生产日期:</td>
<td>
<s:textfield name="date" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>
<tr>
<td>有效期:</td>
<td>
<s:textfield name="limits" cssClass="input" cssStyle="width:90%"/>
</td>
<td>批准文号:</td>
<td>
<s:textfield name="approvalnumber" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>
<tr>
<td>生产单位:</td>
<td>
<s:textfield name="production" cssClass="input" cssStyle="width:90%"/>
</td>
<td>生产地址:</td>
<td>
<s:textfield name="address" cssClass="input" cssStyle="width:90%"/>
</td>
</tr>


  </table>
</div>
</td>
  </tr>
</table>
<br>
</s:form>


</body>
</html>
 

你可能感兴趣的:(js判断为空,返回上一个页面)