CRUD改进

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
    	  $('#SUBMIT').click(function(){
    		 var  name=$("#name").val(); 
    		 var  reg2=/^[a-z]{6,10}$/i;
    		  if(name.length==0){
    			  $("#error2").html("名字不可为空");
    			  return false;
    		  }else if(!reg2.test(name)){
    			  $("#error2").html("请输入6-10位字母");
    			  return  false;
    		  }else{
    			  $("#error2").html("输入正确");
    		  }
    	  })
    	  $("#emai").blur(function(){
           var  email=$("#emai").val();
           var   reg1=/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
  			if(!(reg1).test(email)){
  			$("#error1").html("请输入正确的QQ电子邮箱格式!!");
  			return false;
    		}else{ 
    			$("#error1").html(" 输入正确 !!");
    	  }
    		})
    	$("#date").blur(function(){
           //判断日期格式 
           var  birthday=$("#date").val();
    	   var   reg=/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/;
   		if(!(reg).test(birthday)){
    	   $("#error").html("请输入正确的日期格式!!");
    	   return false;
    		}else{
    	      $("#error").html(" 输入正确 !!");
    		  $('#SUBMIT').submit(); 
    			}
    	})
    	 })
</script>
</head>
<body>
    <form:form  autocomplete="off"  id="button"  name="button" action="${pageContext.request.contextPath }/saveEmp" method="post" modelAttribute="employees">
    <!--两个请求共用一个jsp 所以要判断是哪个请求  -->
    <%--  <c:if test="${empty employees.id}">
    lastName:<form:input path="lastName" />
    <br><br>
    </c:if> --%>
    <c:choose>
    <c:when test="${empty employees.id}">
                 lastName:<form:input path="lastName" size="6" id="name"/>
                 <div id="error2" style="display:inline;color:red;"></div>
    </c:when>
			     <c:otherwise>
                  lastName:<form:input path="lastName" size="10" onclick="lastNa()" id="name"/>
			   <div id="error2" style="display:inline;color:red;"></div>
			     </c:otherwise>
    </c:choose>
    <br><br>
    <c:if test="${employees.id !=null }">
    <form:hidden path="id"/>
    <input type="hidden" name="_method" value="PUT"/>
    </c:if>
    emali:<form:input path="email" id="emai" />
    <div id="error1" style="display:inline;color:red;"></div>
    <form:errors path="email"></form:errors>
    <!--path值要与属性值一致       -->
    <br><br>
    birthday:<form:input path="birthday" id="date" autocomplete="off"/>
    <div id="error" style="display:inline;color:red;"></div>
    <form:errors path="birthday"></form:errors>
    <!--path值要与属性值一致       -->
    <br><br>
    gender:<form:radiobuttons path="gender" items="${genders }" /><form:errors path="gender"></form:errors>
    <br><br>
    departement::<form:select path="department.id" items="${departments }" itemValue="id" itemLabel="departmentName"></form:select>
    <br><br>
    <input type="submit" value="Submit" id="SUBMIT"/>
    </form:form>
    
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值