如何在将数据输入cotrols之前设置强制星标 [英] How to set mandatory star mark before entering data into cotrols

查看:115
本文介绍了如何在将数据输入cotrols之前设置强制星标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii,

i在我的表单中有很多控件,据我所知,我为每个控件设置了必需的fieldvalidator控件,并将text属性设置为*和错误消息属性,并显示正确的错误总结控制,但由于一些未知原因星标在进入之前没有显示,它只在点击按钮后执行,请建议我别的

hii ,
i have many control in my form , As per I know i set required fieldvalidator control for each control and set text property to * and error message property with proper error which will get displayed into summary control , but due to some unknown reason star mark is not gets displayed before entering , it only executes after clicking on button , please suggest me something else

推荐答案

Text属性保持验证失败时显示的消息。

所以当你点击按钮并且验证失败时,你会看到你在Text属性中设置了什么




要最初使用'*',请将其放在可能位于

输入元素之前/之后的标签中。
Text property hold the message to display when the validation fails.
So when you click the button and validation fails you see what you have
set in Text property.

To have '*' initially, have it in a label that might be before/after your
input element.


对于此类示例标记



For a sample markup like this

<asp:Label ID="lblName" runat="server" Text="Enter Name:" ValidationGroup="test"></asp:Label>
        <asp:TextBox ID="txtName" runat="server" ValidationGroup="test"></asp:TextBox>
        <asp:Button ID="btnSubmit" runat="server" ValidationGroup="test" />
        <asp:CustomValidator ControlToValidate="txtName" ID="cvName" ErrorMessage="error" Text="error"

         runat="server" ClientValidationFunction="checkIfValExists" ValidateEmptyText="true" ValidationGroup="test"></asp:CustomValidator>







你可以使用像这样的js函数(这里使用jquery)






You can use a js function like this (jquery is used in here)

function checkIfValExists(source, args) {
        var txt =


(source).prev()。prev()。prev() 。文本();
if
(source).prev().prev().prev().text(); if(


这篇关于如何在将数据输入cotrols之前设置强制星标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆