TextMode="Password" 添加默认字符

<asp:TextBox ID="User_Password" runat="server" TextMode="Password" CssClass="Myinput" MaxLength="16" onfocus="if(value=='......') {value=''}" onblur="if(value=='') {value='......'}"></asp:TextBox>  添加默认字符
User_Password.Attributes.Add("Value", "......");

业务画面:<template> <div class="page-container"> <CustomForm class="project-form" @submit="submitForm"> <h1 class="page-title">项目管理</h1> <div class="form-grid"> <CustomFormItem label="項目ID:" :error="errors.projectId"> <CustomInput v-model="ruleForm.projectId" :disabled="pageMode === 'view' || pageMode === 'edit'" @blur="validateField('projectId')" :maxlength="8" /> </CustomFormItem> <CustomFormItem label="項目名称:" :error="errors.projectName"> <CustomInput v-model="ruleForm.projectName" :disabled="pageMode === 'view'" @blur="validateField('projectName')" :maxlength="10" /> </CustomFormItem> <div class="date-row"> <CustomFormItem label="開始日:" :error="errors.startDate" class="date-item"> <CustomInputDate v-model="ruleForm.startDate" :disabled="pageMode === 'view'" @blur="validateField('startDate')" /> </CustomFormItem> <div class="date-separator">—</div> <CustomFormItem label="終了日:" :error="errors.endDate" class="date-item"> <CustomInputDate v-model="ruleForm.endDate" :disabled="pageMode === 'view'" @blur="validateField('endDate')" /> </CustomFormItem> </div> <CustomFormItem label="項目簡介:" :error="errors.projectDescribtion"> <CustomInputTextarea v-model="ruleForm.projectDescribtion" :disabled="pageMode === 'view'" @blur="validateField('projectDescribtion')" :maxlength="200" :rows="3" /> </CustomFormItem> </div> <div class="form-actions"> <button v-if="pageMode === 'default'" type="submit">登録</button> <button v-if="pageMode === 'edit'" type="submit">更新</button> <button v-if="pageMode === 'edit' || pageMode === 'default'" type="button" @click="resetForm">重置</button> </div> </CustomForm> </div> </template> <script setup> import { ref, reactive, onMounted } from 'vue' import { useRoute } from 'vue-router' import CustomForm from '@/components/zhangaipiao/customForm.vue' import CustomFormItem from '@/components/zhangaipiao/customFormItem.vue' import CustomInput from '@/components/zhangaipiao/inputText.vue' import CustomInputDate from '@/components/zhangaipiao/customInputDate.vue' import CustomInputTextarea from '@/components/zhangaipiao/customInputTextarea.vue' import productApi from '@/api/products' import useUserStore from '@/store/modules/user' // 获取路由参数 const route = useRoute() // 存储表单数据的响应式对象 const ruleForm = reactive({ projectId: '', projectName: '', projectDescribtion: '', startDate: '', endDate: '', employeeId: '', }) // 存储字段验证错误信息的响应式对象 const errors = reactive({ projectId: '', projectName: '', projectDescribtion: '', startDate: '', endDate: '', }) // 页面模式 const pageMode = ref('default') // default, edit, view // 单个字段校验函数 const validateField = (fieldName) => { // 重置该字段的错误信息 errors[fieldName] = '' switch (fieldName) { case 'projectId': if (!ruleForm.projectId) { errors.projectId = '項目ID称は必須です' } else if (ruleForm.projectId.length > 8) { errors.projectId = '項目IDは8文字以内で入力してください' } break; case 'projectName': if (!ruleForm.projectName.trim()) { errors.projectName = '項目名称は必須です' } else if (ruleForm.projectName.trim().length > 10) { errors.projectName = '項目名称は10文字以内で入力してください' } break; case 'startDate': if (!ruleForm.startDate) { errors.startDate = '開始日を選択してください' } else if (ruleForm.endDate && new Date(ruleForm.startDate) > new Date(ruleForm.endDate)) { errors.startDate = '開始日は終了日より前でなければなりません' } break; case 'endDate': if (!ruleForm.endDate) { errors.endDate = '終了日を選択してください' } else if (ruleForm.startDate && new Date(ruleForm.endDate) < new Date(ruleForm.startDate)) { errors.endDate = '終了日は開始日より後でなければなりません' } break; case 'projectDescribtion': if (!ruleForm.projectDescribtion.trim()) { errors.projectDescribtion = '項目簡介を入力してください' } else if (ruleForm.projectDescribtion.trim().length > 200) { errors.projectDescribtion = '項目簡介は200文字以内で入力してください' } } } // 整体表单校验 const validateForm = () => { let valid = true // 校验所有字段 validateField('projectId') validateField('projectName') validateField('startDate') validateField('endDate') validateField('projectDescribtion') // 检查是否有错误 Object.keys(errors).forEach(key => { if (errors[key]) valid = false }) return valid } // 格式化日期函数 const formatDate = (datetimeStr) => { if (!datetimeStr) return '' const date = new Date(datetimeStr) return isNaN(date.getTime()) ? '' : date.toISOString().split('T')[0] } // 在组件挂载时加载数据 onMounted(async () => { // const projectId = route.params.projectId || route.query.projectId // const type = route.query.type // if (type === 'view') { // pageMode.value = 'view' // 查看模式:不显示按钮 // } else if (type === 'edit') { // pageMode.value = 'edit' // 编辑模式:显示“更新”、“重置” // } else { // pageMode.value = 'default' // 默认模式:显示“登录”、“重置” // } const projectId = "123" if ((pageMode.value === 'edit' || pageMode.value === 'view') && projectId) { try { const res = await productApi.getItem(projectId) Object.assign(ruleForm, res.data) // 填充数据到 ruleForm ruleForm.startDate = formatDate(res.data.startDate) ruleForm.endDate = formatDate(res.data.endDate) } catch (error) { console.error('获取项目信息失败:', error) alert('項目情報を取得できませんでした') } } }) // 重置表单 const resetForm = () => { Object.assign(ruleForm, { projectId: '', projectName: '', projectDescribtion: '', startDate: '', endDate: '', }) Object.keys(errors).forEach(key => errors[key] = '') } // 提交表单 const submitForm = async () => { if (!validateForm()) return try { let response // 获取用户名 const userStore = useUserStore() const user = userStore.employeeId ruleForm.employeeId = user if (pageMode.value === 'edit') { // 更新操作 response = await productApi.updateItem(ruleForm) alert('更新成功') } else { // 新增操作 response = await productApi.addItem(ruleForm) alert('登録成功') } console.log('API 响应:', response.data) // 可选:提交成功后跳转页面 // router.push('/project/list') } catch (error) { console.error('API 请求失败:', error) alert('提交失败,请检查网络或输入内容') } } </script> <style scoped src="@/assets/styles.css"></style> form组件:<template> <div class="custom-card"> <form class="custom-form" @submit.prevent="$emit('submit')"> <slot></slot> </form> </div> </template> <script> export default { emits: ['submit'] } </script> <style scoped src="@/assets/styles.css"></style> formItem子组件:<template> <div class="form-item"> <label v-if="label" class="form-label">{{ label }}</label> <div> <slot></slot> <div v-if="error" class="error-message"> {{ error }} </div> </div> </div> </template> <script> export default { props: { label: String, error: String } } </script> <style scoped src="@/assets/styles.css"></style> input组件:<template> <div class="input-wrapper"> <input :type="inputType" :value="modelValue" @input="$emit('update:modelValue', $event.target.value)" class="input-text" :class="{ error: error }" :placeholder="placeholder" /> <span v-if="showPassword && type === 'password'" class="password-toggle" @click="togglePasswordVisibility" > {{ passwordVisible ? '隐藏' : '显示' }} </span> </div> </template> <script> import { ref, computed } from 'vue'; export default { props: { modelValue: String, type: { type: String, default: 'text' }, placeholder: String, showPassword: Boolean, error: Boolean }, emits: ['update:modelValue'], setup(props) { const passwordVisible = ref(false); const inputType = computed(() => { if (props.type === 'password' && passwordVisible.value) { return 'text'; } return props.type; }); const togglePasswordVisibility = () => { passwordVisible.value = !passwordVisible.value; }; return { passwordVisible, inputType, togglePasswordVisibility }; } } </script> <style scoped src="@/assets/styles.css"></style> 他们之间是怎么工作的
最新发布
07-25
<%@ Page Language=“C#” AutoEventWireup=“true” CodeFile=“AddNewUser.aspx.cs” Inherits=“Admin_lizhitong_AddNewUser” %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=“http://www.w3.org/1999/xhtml”> <head runat=“server”> <title>注册新用户</title> <link href=“/css/Style.css” rel=“stylesheet” type=“text/css” /> </head> <body> <form id=“form1” runat=“server”> <div> <table border=“0” width=“100%” cellspacing=“1” cellpadding=“2” id=“table2” class=“tableBorder”> <tr> <th valign=“middle” colspan=“2” height=“25”> <table align=“center” width=“100%”> <tr> <td width=“96%” colspan=“2”> 注册用户 </td> </tr> </table> </th> </tr> <tr> <td width=“150” height=“47” align=“center” class=“forumRow”> 用户名: </td> <td class=“forumRow” align=“left”> <asp:TextBox ID=“tbYHM” runat=“server” Height=“19px” Width=“200px” spellcheck=“false” autocomplete=“off” aria-autocomplete=“none”></asp:TextBox> </td> </tr> <tr> <td width=“150” height=“47” align=“center” class=“forumRow”> 用户密码: </td> <td class=“forumRow” align=“left”> <asp:TextBox ID=“tbYHMM” runat=“server” Height=“19px” Width=“200px” spellcheck=“false” autocomplete=“off” aria-autocomplete=“none”></asp:TextBox> </td> </tr> <tr> <td width=“150” height=“47” align=“center” class=“forumRow”> 确认密码: </td> <td class=“forumRow” align=“left”> <asp:TextBox ID=“tbQRMM” runat=“server” Height=“19px” Width=“200px” spellcheck=“false” autocomplete=“off” aria-autocomplete=“none”></asp:TextBox> <asp:Literal ID=“mmErrorMessage” runat=“server”></asp:Literal> </td> </tr> <tr> <td width=“150” height=“47” align=“center” class=“forumRow”> 用户姓名: </td> <td class=“forumRow” align=“left”> <asp:TextBox ID=“tbYHXM” runat=“server” Height=“19px” Width=“200px” spellcheck=“false” autocomplete=“off” aria-autocomplete=“none”></asp:TextBox> </td> </tr> <tr> <td width=“80” height=“47” align=“center” class=“forumRow”> 所属区域: </td> <td class=“forumRow” align=“left”> <div class=“dropdown-container” style=“max-width: 450px;”> <asp:DropDownList ID=“ddlZJ” CssClass=“custom-dropdown” runat=“server” AutoPostBack=“True” onselectedindexchanged=“ddlZJ_SelectedIndexChanged”></asp:DropDownList> <asp:DropDownList ID=“ddlPCS” CssClass=“custom-dropdown” runat=“server” AutoPostBack=“True” onselectedindexchanged=“ddlPCS_SelectedIndexChanged”></asp:DropDownList> <asp:DropDownList ID=“ddlVillage” CssClass=“custom-dropdown” runat=“server” AutoPostBack=“True”></asp:DropDownList> </div> </td> </tr> <tr> <td width=“150” height=“47” align=“center” class=“forumRow”> 工作单位: </td> <td class=“forumRow” align=“left”> <asp:TextBox ID=“tbGZDW” runat=“server” Height=“19px” Width=“200px” spellcheck=“false” autocomplete=“off” aria-autocomplete=“none”></asp:TextBox> <td class=“forumRow” align=“left”> <asp:DropDownList ID=“ddlYHJS” CssClass=“custom-dropdown” style=“width:300px;” runat=“server”></asp:DropDownList> </td> </tr> <tr> <td valign="middle" colspan="2" align="center" class="forumRow"> <span style="color: Red; padding-left: 10px;"> <asp:Button ID="btSubmit" runat="server" Text="提交注册" OnClick="btSubmit_Click" />  <asp:Literal ID="ltMessage" runat="server"></asp:Literal></span> </td> </tr> </table> </div> </form> </body> </html> 怎么让tbQRMM和tbYHMM显示为*号,不用TextMode="Password"方法
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值