检查validation ,出错输入框会变红色,




1.由<td><input type="password" name="password" class="form-control"/></td>

input 框改写为:

<td style="background-color: #f9f9f9;">原密码</td>
<td><form:input type="password" path="password" cssClass="form-control" cssErrorClass="form-control error" /></td>
<td style="background-color: #f9f9f9;">新密码</td>
<td><form:input type="password" path="passwordNew"  cssClass="form-control" cssErrorClass="form-control  error"/></td>
<td style="background-color: #f9f9f9;">密码确认</td>
<td><form:input type="password" path="passwordConfirm"  cssClass="form-control"  cssErrorClass="form-control error"/></td>
<td style="background-color: #f9f9f9;">终端价</td>						
<td><form:input path="retailPrice" cssClass="form-control" cssErrorClass="form-control error" value="${distributorPriceForm.retailPrice}" /></td>

2.新建css文件夹-commom.css文件

.error {

background-color: red;  }

3.添加颜色链接

 <link href="css/common.css" rel="stylesheet">

4加红色的星:

<td style="background-color: #f9f9f9;">原密码<span style="color:red;">*</span></td>

5“取消”按钮的链接

 <a href="initMenu" class="btn btn-danger">取消</a>

validation代码

1.DistributorForm.java

@NotEmpty(field="密码",  message="{errors.required}")

private String password;

@NotEmpty(field="新密码",  message="{errors.required}")

private String passwordNew;

@NotEmpty(field="密码确认",  message="{errors.required}")

private String passwordConfirm;

2.@RequestMapping(value = "editDistributorPassword", method = RequestMethod.POST)

public String executeEditDistributorPassword(Model model, HttpSession session, @Valid @ModelAttribute("distributorForm") DistributorForm distributorForm, BindingResult results) throws SQLException {

if(results.hasErrors())

{

                  return "manager/distributor/editDistributorPassword";

}


你可能感兴趣的:(检查validation ,出错输入框会变红色,)