学习javaweb的时候,做了将页面上的的表单信息添加到数据库中的练习。提交表单的时候,需要保证每个输入框、单选按钮、复选框等都不为空,刚开始的时候挨个获取控件的值进行判断是否为空,后来认识了表单序列化这么一个方法,就是了下用序列化来判断空值
//form表单页面
<form id="basicInfo" action="EmployeeServlet?flag=addEmployeeInfo" method="post"> <div class="formbody"> <div class="formtitle"><span>基本信息</span></div> <ul class="forminfo"> <li> <label>员工账号</label> <input id="account" name="account" type="text" class="dfinput" readOnly="true" /> <i>设置员工姓名和入职时间后,系统自动生成,无法更改</i> </li> <li> <label>员工姓名</label> <input name="name" type="text" class="dfinput" id="name" /> <i>姓名不能为数字</i> </li> <li> <label>密码</label> <input name="password" type="password" class="dfinput" id="pwd" placeholder="空值或空白则默认密码为123456" /> <i></i> </li> <li> <label>性别</label> <cite> <input name="gender" type="radio" value="男" checked="checked" />男 <input name="gender" type="radio" value="女" />女 </cite> </li> <li> <label>生日</label> <input id="birth" name="birthday" type="text" class="dfinput" placeholder="格式:yyyy-mm-dd"/> <i id = "birthTip"></i> </li> <li> <label>手机号码</label> <input id="phone" name="telephone" type="text" class="dfinput" /> <i id = "phoneTip"></i> </li> <li> <label>邮箱</label> <input id="email" name="email" type="text" class="dfinput" /> <i id = "emailTip"></i> </li> <li> <label>地址</label> <input name="address" type="text" class="dfinput" /> <i id = "addressTip"></i> </li> <li> <label>所属部门</label> <select id="dept" class="dfinput" name="dept"> </select> </li> <li> <label>入职时间</label> <input id="entrytime" name="entrytime" type="text" class="dfinput" placeholder="格式:yyyy-mm-dd" /> <i id = "timeTip"></i> </li> <li> <label>员工状态</label> <select id="empstate" class="dfinput" name="empstate"> </select> </li> <li> <label>直属上级</label> <input id="superior" name="superior" type="text" class="dfinput" placeholder="直属上级员工id" /> <i id = "superTip"></i> </li> <li> <label>职务</label> <select id="dutyid" class="dfinput" name="dutyid"> </select> </li> <li> <label>角色权限</label> <select id="authority" class="dfinput" name="authority"> </select> </li> <li> <label> </label> <input id="savebtn" type="submit" class="btn" value="确认保存"/> </li> </ul> </div></form>
新闻热点
疑难解答
图片精选