\继大概只有自己能懂的干货 注册表单密码RSA加密 再续写表单验证。
因为项目用的是bootstrap,所以就将就到底,直接用bootstrapvalidate 插件了。
两个插件文件引进来先,可以在官网下载
1. bootstrapValidator.min.css
2. bootstrapValidator.min.js
随便找个页面吧,修改密码的页面,只有三个密码框,但是数据都要加密。直接看代码就知道怎么用了,查查插件的api就知道怎么用了。
<script type="text/javascript">
$(function () {
$('#UpdatePasswordForm').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
Password: {
validators: {
notEmpty: {
message: '请输入當前密码。'
},
regexp: {
regexp: /^((?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,})$/,
message: '原密碼格式錯誤'
}
}
},
NewPassword: {
validators: {
notEmpty: {
message: '请输入新密码。'
},
regexp: {
regexp: /^((?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,})$/,
message: '密碼格式不符'
}
}
},
ConfirmPassword: {
validators: {
notEmpty: {
message: '请输入确认密码。'
},
identical: {
field: 'NewPassword',
message: '两次输入的密码不一致。'
}
}
}
}//fields End
})
.on('success.field.fv', function(e, data) {
if