jQuery为<input />标签添加“disable”和去除“disable”属性

本文展示了如何使用JavaScript来禁用和启用HTML输入标签的按钮,通过修改DOM属性实现按钮状态的切换。
$("#subButton").attr("disabled","disabled");//禁用input标签
$("#subButton").attr("disabled",false);//启用input标签
<html> <head> <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <!-- 最新版本的 Bootstrap 核心 CSS 文件 --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- 可选的 Bootstrap 主题文件(一般不用引入) --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> <!-- 最新的 Bootstrap 核心 JavaScript 文件 --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <script lang="javascript"> </script> </head> <body> <form> <div style="width:500px;margin:10px auto;text-align: center;"> <div style="font-size:28px;font-weight:bold;margin:0px auto;">user signup</div> <br /> <table style="width:100%;text-align: left;"> <tbody> <tr style="margin-bottom: 20px;"> <td> <span class="p">*</span> <label for="username" class="l"> new username:</label> </td> <td> <input id="username" type="text" style="height:30px;width:250px;padding-right:50px;"> </td> </tr> <tr> <td><br></td> <td></td> </tr> <tr style="margin-bottom: 20px;"> <td> <span class="p">*</span> <label for="password" class="l"> password:</label> </td> <td> <input id="password" type="text" style="height:30px;width:250px;padding-right:50px;"> </td> </tr> <tr> <td><br></td> <td></td> </tr> <tr style="margin-bottom: 20px;"> <td> <span class="p">*</span> <label for="passwordc" class="l"> repeated password:</label> </td> <td> <input id="passwordc" type="text" style="height:30px;width:250px;padding-right:50px;"> </td> </tr> <tr> <td><br></td> <td></td> </tr> <tr> <td> </td> <td> <input class="btn btn-success" type="button" style="margin:0 auto;width:250px;" value="click to signup" onclick='onSignup()' /> <label name='login_hint' id='login_hint' style='display:none'>sigup success!</label> </td> </tr> </tbody> </table> </div> </form> </body> <script lang="javascript"> function onSignup() { var username = document.getElementById('username'); var password = document.getElementById('password'); $.ajax({ url: "/user/signup", type: "POST", data: { "username": username.value, "password": password.value }, error: function (jqXHR, textStatus, errorThrown) { if (textStatus == "error") { alert(textStatus + " : " + errorThrown); } else { alert(textStatus); } }, success: function (data, textStatus, jqXHR) { if (data == 'SUCCESS') { // 成功后跳到登录页 document.getElementById("login_hint").style.display = "block"; setTimeout(() => { window.location.href = '/static/view/signin.html'; }, 2000); } else { alert('signup fail!'); } } }); } </script> </html> 换成https后还是出现错误
03-27
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="zh-CN" class="bootstrap-admin-vertical-centered"> <head> <meta charset="UTF-8"> <title>图书馆管理系统</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="static/css/bootstrap.min.css"> <link rel="stylesheet" href="static/css/bootstrap-theme.min.css"> <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css"> <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css"> <script src="static/js/bootstrap.min.js"></script> <script src="static/jQuery/jquery-3.1.1.min.js"></script> <script src="static/ajax-lib/ajaxutils.js"></script> <script src="static/js/login.js"></script> </head> <style type="text/css"> .alert{ margin: 0 auto 20px; text-align: center; } </style> <script src="static/js/jquery.min.js"></script> <script src="static/js/bootstrap.min.js"></script> <body class="bootstrap-admin-without-padding"> 池州学院 230312242 杨洪博 课设 <div style="background-image: url('image/2.png'); background-size: cover; background-repeat: no-repeat; background-position: center;"></div> <div class="col-lg-12"> <div class="alert alert-info"> <a class="close" data-dismiss="alert" href="#">×</a> 欢迎登录图书馆管理系统 </div> <form class="bootstrap-admin-login-form" method="post" action="/books/LoginServlet"> <% String state = (String)session.getAttribute("state"); session.removeAttribute("state"); if(state!=null){ %> <label class="control-label" for="username">密码错误</label> <%}%> <div class="form-group"> <label class="control-label" for="username">账 号</label> <input type="text" class="form-control" id="username" name="username" required="required" placeholder="学号"/> <label class="control-label" for="username" style="display:none;"></label> </div> <div class="form-group"> <label class="control-label" for="password">密 码</label> <input type="password" class="form-control" id="password" name="password" required="required" placeholder="密码"/> <label class="control-label" for="username" style="display:none;"></label> </div> <label class="control-label" for="password">没有账号请<a href="/books/register.jsp" style="color:blue;">注册</a></label> <br> <input type="submit" class="btn btn-lg btn-primary" value="登    录"/> </form> </div> </div> </div> <div class="modal fade" id="modal_info" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="infoModalLabel">提示</h4> </div> <div class="modal-body"> <div class="row"> <div class="col-lg-12" id="div_info"></div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" id="btn_info_close" data-dismiss="modal">关闭</button> </div> </div> </div> </div> </body> </html>文件路径没问题 但图片显示不出来
06-22
实现第二个tab页根据devid查询设备信息 <!DOCTYPE html> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <head> <th:block th:include="include :: header('设备台帐管理列表')" /> <th:block th:include="include :: layout-latest-css" /> <th:block th:include="include :: ztree-css" /> </head> <body class="gray-bg"> <div class="ui-layout-west"> <div class="box box-main"> <div class="box-header"> <div class="box-title"> <i class="fa icon-grid"></i> 组织机构 </div> <div class="box-tools pull-right"> <a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a> <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button> <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button> <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button> </div> </div> <div class="ui-layout-content"> <div id="tree" class="ztree"></div> </div> </div> </div> <div class="ui-layout-center"> <div class="container-div"> <div class="row"> <!-- 页签开始 --> <div class="ibox-content"> <!-- <form id="formId"> <input type="hidden" id="parentId" name="parentId"> </form> --> <ul class="nav nav-tabs"> <!-- { text: "设备列表", name: "devlist", alias:"devlist",visible:true}, { text: "设备信息", name: "devinfo" ,alias:"devinfo",visible:true}, { text: "扩展属性", name: "devext" ,alias:"devext",visible:true}, { text: "物料清单", name: "devbom" ,alias:"devbom",visible:true}, { text:"文档清单", name:"devdoc",alias:"devdoc",visible:true}, { text: "检修记录", name: "overhaulrecord" ,alias:"overhaulrecord",visible:true}, { text: "养护计量", name: "curingmeasure" ,alias:"curingmeasure",visible:true}, { text: "安装历史", name: "installationhistory" ,alias:"installationhistory",visible:true} --> <li class="active"><a data-toggle="tab" aria-expanded="true" onclick="queryDevlist()">设备列表</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="devinfo()">设备信息</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="devext()">扩展属性</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="devbom()">物料清单</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="devdoc()">文档清单</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="overhaulrecord()">检修记录</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="curingmeasure()">养护计量</a></li> <li><a data-toggle="tab" aria-expanded="false" onclick="installationhistory()">安装历史</a></li> <!-- <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 第一个选项卡</a> </li> <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">第二个选项卡</a> </li> --> </ul> </div> <!-- 页签结束 --> <div class="col-sm-12 search-collapse"> <form id="devledger-form"> <input type="hidden" id="deptId" name="deptId"> <input type="hidden" id="devSiteId" name="devSiteId"> <div class="select-list"> <ul> <li> <label>设备名称:</label> <input type="text" name="devName"/> </li> <li> <label>固定资产编码:</label> <input type="text" name="assetCode"/> </li> <li> <label>生产厂家:</label> <input type="text" name="factory"/> </li> <!-- <li> 设备状态:<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}"> <option value="">所有</option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> </select> </li> --> <li> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a> <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a> </li> </ul> </div> </form> </div> <div class="btn-group-sm" id="toolbar" role="group"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:devledger:add"> <i class="fa fa-plus"></i> 新建 </a> <!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:devledger:edit"> <i class="fa fa-edit"></i> 修改 </a> --> <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:devledger:remove"> <i class="fa fa-remove"></i> 删除 </a> <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:devledger:export"> <i class="fa fa-download"></i> 导出 </a> </div> <div class="col-sm-12 select-table table-striped" style="overflow-y: auto;height: 250px;"> <table id="bootstrap-table"></table> </div> </div> </div> </div> <th:block th:include="include :: footer" /> <th:block th:include="include :: layout-latest-js" /> <th:block th:include="include :: ztree-js" /> <script th:inline="javascript"> //var editFlag = [[${@permission.hasPermi('system:devledger:edit')}]]; //var removeFlag = [[${@permission.hasPermi('system:devledger:remove')}]]; var prefix = ctx + "system/devledger"; var selectedDeviceId = ""; //判断当前元素的宽度,动态决定侧边栏是否隐藏 $(function() { var panehHidden = false; if ($(this).width() < 769) { panehHidden = true; } $('body').layout({ initClosed: panehHidden, west__size: 185 }); queryDevlist(); queryLocationTree(); }); //不同页签的按钮设定 var ButtonManager = { templates: { devlist: ` <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:location:add"> <i class="fa fa-plus"></i> 新建 </a> <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:location:remove"> <i class="fa fa-remove"></i> 删除 </a> <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:location:export"> <i class="fa fa-download"></i> 导出 </a> `, devinfo: ` <a class="btn btn-success" onclick="$.operate.save()" shiro:hasPermission="system:base:save"> <i class="fa fa-plus"></i> 保存 </a> <a class="btn btn-primary single disabled" onclick="$.operate.printnum()" shiro:hasPermission="system:base:printnum"> <i class="fa fa-edit"></i> 打印条形码 </a> <a class="btn btn-danger multiple disabled" onclick="$.operate.printform()" shiro:hasPermission="system:base:printform"> <i class="fa fa-remove"></i> 打印台账 </a> <a class="btn btn-warning" onclick="$.operate.renewal()" shiro:hasPermission="system:base:renewal"> <i class="fa fa-download"></i> 设备续保 </a> `, devext: ` <a class="btn btn-warning" onclick="$.operate.save()" shiro:hasPermission="system:base:save"> <i class="fa fa-download"></i> 保存 </a> `, devbom: `//此页签中包含设备物料清单、设备配套耗材、设备配套文档三个功能增删改查 <a class="btn btn-warning" onclick="$.operate.save()" shiro:hasPermission="system:base:save"> <i class="fa fa-download"></i> 保存 </a> ` }, change: function(buttonType) { if (this.templates[buttonType]) { $('#toolbar').html(this.templates[buttonType]); return true; } return false; }, // 切换到设备列表按钮 toDevlist: function() { return this.change('devlist'); }, // 切换到设备信息按钮 toDevinfo: function() { return this.change('devinfo'); }, // 切换到扩展属性按钮 toDevext: function() { return this.change('devext'); }, // 切换到物料清单按钮 toDevbom: function() { return this.change('devbom'); }, // 切换到文档清单按钮 toDevdoc: function() { return this.change('devdoc'); }, // 切换到检修记录按钮 toOverhaulrecord: function() { return this.change('overhaulrecord'); }, // 切换到养护计量按钮 toCuringmeasure: function() { return this.change('curingmeasure'); }, // 切换到安装历史按钮 toInstallationhistory: function() { return this.change('installationhistory'); } }; //查询设备列表 function queryDevlist() { var options = { url: prefix + "/list", createUrl: prefix + "/add", /* updateUrl: prefix + "/edit/{id}", */ removeUrl: prefix + "/remove", exportUrl: prefix + "/export", /* sortName: "createTime", sortOrder: "desc", */ modalName: "设备台帐管理", columns: [{ checkbox: true }, { field: 'devCode', title: '设备编码' }, { field: 'devName', title: '设备名称' /* title: '设备名称', sortable: true */ }, { field: 'devTypeId', title: '设备类型'//设备类型ID }, { field: 'devSpecksId', title: '设备型号' }, { field: 'factory', title: '生产厂家' }, { field: 'assetCode', title: '固定资产编码' }, { field: 'devStatus', title: '设备状态', align: 'center', formatter: function (value, row, index) { return statusTools(row); } }, { field: 'wzCode', title: '物资编码', visible: false // 隐藏该列 }, { field: 'snCode', title: 'SN编码', visible: false // 隐藏该列 }, { title: '操作', align: 'center', visible: false, // 隐藏该列 formatter: function(value, row, index) { var actions = []; actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.devId + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.devId + '\')"><i class="fa fa-remove"></i>删除</a>'); return actions.join(''); } } ], onLoadSuccess: function(data) { // 表格数据加载成功后执行 if (data && data.row.length > 0) { // 获取第一行数据 var firstRow = data.row[0]; selectedDeviceId = firstRow.devId; console.log("第一行设备ID:", selectedDeviceId); } }, // 添加双击行的回调函数 onDblClickRow: function (row, $element) { // 这里编写跳转至第二个 tab 页的逻辑 // 假设使用 jQuery 来切换 tab 页,第二个 tab 的 id 为 tab2 $('#tab2').tab('show'); } }; $.table.init(options); } function devinfo() { // 跳转到设备信息页面并传递参数 window.location.href = 'add.html?devId=' + selectedDeviceId; } function devext(){ /* prefix = ctx + "system/base"; */ debugger; var options2 = { /* id:'bootstrap-table', url: prefix + "/list", createUrl: prefix + "/add", updateUrl: prefix + "/edit/{id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", modalName: "设备基础信息", */ url: prefix + "/devext", createUrl: prefix + "/add", /* updateUrl: prefix + "/edit/{id}", */ removeUrl: prefix + "/remove", exportUrl: prefix + "/export", /* sortName: "createTime", sortOrder: "desc", */ modalName: "设备信息", columns: [{ checkbox: true }, /* { field: 'devId', title: '设备ID', visible: false }, */ { field: 'devCode', title: '设备编码' }, { field: 'devName', title: '设备名称' }, { field: 'professionName', title: '专业名称' }, { field: 'devSpecksId', title: '设备型号' }, { field: 'measurementFlag', title: '计量标志' }, { field: 'maintenanceFlag', title: '养护标志' }, { field: 'devStatus', title: '设备状态' }, { field: 'statuDate', title: '当前状态日期' }, { field: 'userDevFlag', title: '是否用户设备' }, { field: 'factory', title: '生产厂家' }, { field: 'zclb', title: '管理分类' } , { title: '操作', align: 'center', formatter: function(value, row, index) { var actions = []; actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.devId + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.devId + '\')"><i class="fa fa-remove"></i>删除</a>'); return actions.join(''); } } ] }; debugger; reinitializeTable(options2); //$.table.init(options2); ButtonManager.toEquit(); // 切换回新增按钮 $.table.search(); } //查询树形结构 function queryLocationTree() { var url = ctx + "system/devledger/treeData"; var options = { url: url, expandLevel: 2, onClick : zOnClick }; $.tree.init(options); function zOnClick(event, treeId, treeNode) { $("#devSiteId").val(treeNode.id); //$("#devSiteId").val(treeNode.pId); //$("#title").val(treeNode.pId); $.table.search(); } } //树形结构的展开折叠刷新 $('#btnExpand').click(function() { $._tree.expandAll(true); $(this).hide(); $('#btnCollapse').show(); }); $('#btnCollapse').click(function() { $._tree.expandAll(false); $(this).hide(); $('#btnExpand').show(); }); $('#btnRefresh').click(function() { queryLocationTree(); }); /* 树形结构-部门 */ function dept() { var url = ctx + "system/type"; $.modal.openTab("部门管理", url); } /* 设备状态显示 */ function statusTools(row) { if (row.devStatus == "active") { return '在用'; //return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> '; } else if (row.devStatus == "tobeinstall") { return '待安装'; //return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> '; } else if (row.devStatus == "inactive") { return '停用'; //return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> '; }else if (row.devStatus == "discard") { return '报废'; //return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> '; } } </script> </body> </html>
最新发布
10-17
这是视图:@page @model ChangePasswordModel @{ ViewData["Title"] = "修改密码"; ViewData["ActivePage"] = ManageNavPages.ChangePassword; } <h3>@ViewData["Title"]</h3> <div class="row"> <div class="col-md-6"> <form id="change-password-form" method="post"> <div asp-validation-summary="ModelOnly" class="text-danger" role="alert"></div> <div class="form-floating mb-3"> <input asp-for="Input.OldPassword" class="form-control" autocomplete="current-password" aria-required="true" placeholder="请输入您的旧密码。" /> <label asp-for="Input.OldPassword" class="form-label">旧密码</label> <span asp-validation-for="Input.OldPassword" class="text-danger"></span> </div> <div class="form-floating mb-3"> <input asp-for="Input.NewPassword" class="form-control" autocomplete="new-password" aria-required="true" placeholder="请输入您的新密码。" /> <label asp-for="Input.NewPassword" class="form-label">新密码</label> <span asp-validation-for="Input.NewPassword" class="text-danger"></span> </div> <div class="form-floating mb-3"> <input asp-for="Input.ConfirmPassword" class="form-control" autocomplete="new-password" aria-required="true" placeholder="请确认您的新密码。"/> <label asp-for="Input.ConfirmPassword" class="form-label">确认新密码</label> <span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span> </div> <button type="submit" class="w-100 btn btn-lg btn-primary">更新密码</button> </form> </div> </div> @section Scripts { <partial name="_ValidationScriptsPartial" /> } 这是控制器:// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable disable using System; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using UserManagementSystem.Web.Models; namespace UserManagementSystem.Web.Areas.Identity.Pages.Account.Manage { public class ChangePasswordModel : PageModel { private readonly UserManager<ApplicationUser> _userManager; private readonly SignInManager<ApplicationUser> _signInManager; private readonly ILogger<ChangePasswordModel> _logger; public ChangePasswordModel( UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager, ILogger<ChangePasswordModel> logger) { _userManager = userManager; _signInManager = signInManager; _logger = logger; } /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> [BindProperty] public InputModel Input { get; set; } /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> [TempData] public string StatusMessage { get; set; } /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public class InputModel { /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> [Required] [DataType(DataType.Password)] [Display(Name = "Current password")] public string OldPassword { get; set; } /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> [Required] [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "New password")] public string NewPassword { get; set; } /// <summary> /// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> [DataType(DataType.Password)] [Display(Name = "Confirm new password")] [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] public string ConfirmPassword { get; set; } } public async Task<IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var hasPassword = await _userManager.HasPasswordAsync(user); if (!hasPassword) { return RedirectToPage("./SetPassword"); } return Page(); } public async Task<IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return Page(); } var user = await _userManager.GetUserAsync(User); if (user == null) { return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword); if (!changePasswordResult.Succeeded) { foreach (var error in changePasswordResult.Errors) { ModelState.AddModelError(string.Empty, error.Description); } return Page(); } await _signInManager.RefreshSignInAsync(user); _logger.LogInformation("User changed their password successfully."); StatusMessage = "Your password has been changed."; return RedirectToPage(); } } } 请给我修改这两个代码,要求:我只要密码修改功能,其他功能不要
10-06
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值