前端表单验证的重要性这里就不多说了,下面是前段时间做的通过自定义规则验证用户名是否唯一。
-
首选肯定要引人jQuery和valitation的相关文件。
1 |
<script src= "${ctx}/static/jquery/jquery-1.11.0.min.js" type= "text/javascript" ></script> |
2 |
<link href= "${ctx}/static/jquery-validation/1.11.1/validate.css" type= "text/css" rel= "stylesheet" /> |
3 |
<script src= "${ctx}/static/jquery-validation/1.11.1/jquery.validate.min.js" type= "text/javascript" ></script> |
4 |
<script src= "${ctx}/static/jquery-validation/1.11.1/messages_bs_zh.js" type= "text/javascript" ></script> |
2. 页面需要验证的表单。
1 |
< form id = "inputForm" class = "" action = "" > |
2 |
< label class = "col-md-2 " >登录账号:</ label > |
3 |
< input type = "text" |