修改BUG:个人中心保存显示名称与更改密码没有客户端验证
This commit is contained in:
parent
1b9d44d68a
commit
9f1d4650f6
|
@ -129,12 +129,13 @@
|
|||
});
|
||||
that.animate({ marginTop: "+=" + getHeight() });
|
||||
},
|
||||
autoValidate: function (options) {
|
||||
autoValidate: function (options, handler) {
|
||||
// validate
|
||||
$(this).validate({
|
||||
var $this = $(this);
|
||||
$this.validate({
|
||||
validClass: "has-success",
|
||||
errorClass: "has-error",
|
||||
ignore: "ignore",
|
||||
ignore: ".ignore",
|
||||
rules: $.extend({}, options),
|
||||
highlight: function (element, errorClass, validClass) {
|
||||
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
|
||||
|
@ -156,6 +157,13 @@
|
|||
$(element).popover('show');
|
||||
}
|
||||
});
|
||||
if ($.isArray(handler.button)) {
|
||||
$.each(handler.button, function (index, btn) {
|
||||
$('#' + btn).on('click', function () {
|
||||
$(this).attr('data-valid', $this.valid());
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
smartTable: function (options) {
|
||||
var settings = $.extend({
|
||||
|
|
|
@ -19,6 +19,32 @@
|
|||
if (!!url) $headerIcon.attr('src', url);
|
||||
});
|
||||
|
||||
$('#infoDataForm').autoValidate({
|
||||
displayName: {
|
||||
required: true,
|
||||
maxlength: 50
|
||||
}
|
||||
}, {
|
||||
button: ['btnSaveDisplayName']
|
||||
});
|
||||
$('#passwordDataForm').autoValidate({
|
||||
currentPassword: {
|
||||
required: true,
|
||||
maxlength: 50
|
||||
},
|
||||
newPassword: {
|
||||
required: true,
|
||||
maxlength: 50
|
||||
},
|
||||
confirmPassword: {
|
||||
required: true,
|
||||
equalTo: "#newPassword",
|
||||
maxlength: 50
|
||||
}
|
||||
}, {
|
||||
button: ['btnSavePassword']
|
||||
});
|
||||
|
||||
var bsa = new BootstrapAdmin({
|
||||
url: '../api/Infos',
|
||||
bootstrapTable: null,
|
||||
|
@ -34,12 +60,15 @@
|
|||
assign: [{
|
||||
id: 'btnSavePassword',
|
||||
click: function (row, data) {
|
||||
if ($(this).attr('data-valid') == "true") {
|
||||
data.UserStatus = 2;
|
||||
User.changePassword(data);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
id: 'btnSaveDisplayName',
|
||||
click: function (row, data) {
|
||||
if ($(this).attr('data-valid') == "true") {
|
||||
data.UserStatus = 1;
|
||||
User.saveUserDisplayName(data, function (result) {
|
||||
if (result) {
|
||||
|
@ -47,6 +76,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<script src="~/content/js/sweetalert.js"></script>
|
||||
<script src="~/Content/js/fileinput.js"></script>
|
||||
<script src="~/Content/js/fileinput.zh.js"></script>
|
||||
<script src="~/Content/js/jquery.validate.js"></script>
|
||||
<script src="~/Content/js/messages_zh.js"></script>
|
||||
<script src="~/scripts/Infos.js"></script>
|
||||
}
|
||||
@section css {
|
||||
|
@ -28,7 +30,7 @@
|
|||
<div class="row">
|
||||
<div class="form-group col-xs-12 col-sm-6">
|
||||
<label class="control-label" for="userName">登陆名称</label>
|
||||
<input type="text" class="form-control" id="userName" name="userName" value="@Model.UserName" readonly />
|
||||
<input type="text" class="form-control ignore" id="userName" name="userName" value="@Model.UserName" readonly />
|
||||
</div>
|
||||
<div class="form-group col-xs-12 col-sm-6">
|
||||
<label class="control-label" for="DisplayName">显示名称</label>
|
||||
|
@ -46,15 +48,15 @@
|
|||
<div class="panel-body">
|
||||
<form id="passwordDataForm" name="passwordDataForm" class="form-inline" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-xs-12">
|
||||
<div class="form-group col-lg4 col-md-4 col-sm-12 col-xs-12">
|
||||
<label class="control-label" for="currentPassword">当前密码: </label>
|
||||
<input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="登陆密码" maxlength="50" />
|
||||
</div>
|
||||
<div class="form-group col-xs-6">
|
||||
<div class="form-group col-lg-4 col-md-4 col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="newPassword">最新密码: </label>
|
||||
<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码" maxlength="50" />
|
||||
</div>
|
||||
<div class="form-group col-xs-6">
|
||||
<div class="form-group col-lg-4 col-md-4 col-sm-6 col-xs-12">
|
||||
<label class="control-label" for="confirmPassword">确认密码: </label>
|
||||
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致" maxlength="50" />
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue