<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加部门</title>
<script>
function check(formID){
var dp = $('#' + formID).val();
if(dp.dname=="" || dp.dname == null){
alert("部门名称不能为空!");
return false;
}
if(dp.dtel==""|| dp.del == null){
alert("电话不能为空!");
return false;
}
}
</script>
</head>
<body>
<form:form modelAttribute="department" id="formID" method="post">
<fieldset>
<legend>添加部门</legend>
<p>
<label>部门名:</label>
<form:input path="dname" name = "dname" id="dname"/>
</p>
<p>
<label>电话:</label>
<form:input path="dtel" name = "dtel" id = "dtel"/>
</p>
<p>
<label>描述:</label>
<form:textarea path="describe" rows="5"/>
</p>
<p>
<label>上级部门:</label>
<form:select path="superdepartment">
<option value="0"/>请选择上级部门
<form:options items="${superdepartment }" itemLabel="dname" itemValue="id"/>
</form:select>
</p>
<p id="buttons">
<input id="reset" type="reset">
<input type="submit" value="提交" onclick="return check(formID)">
</p>
</fieldset>
</form:form>
</body>
</html>
请教一下这个前端JSP页面数据校正的时候点提交没反应是什么问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
关注 我没用过这个方法。
<form:input path="dtel" name = "dtel" id = "dtel"/> 文本框不就是文本框吗? <input>f</input>
function check(formID){ var dp = $('#' + formID).val(); 直接var dp=('#dname ‘).val(); 获取部门文本框值 if(dp.dname=="" || dp.dname == null){ 判断if(dp==""||dp==null) alert("部门名称不能为空!"); return false; } if(dp.dtel==""|| dp.del == null){ alert("电话不能为空!"); return false; } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog
- ¥15 Excel发现不可读取的内容
- ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
- ¥20 yolov5自定义Prune报错,如何解决?