I'm trying to add RequiredFieldValidator behind the <input>
.
The following is my code:
<form id="form1" runat="server">
<div>
<input type="text" id="MID" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<br />
</div>
</form>
Then, I'm trying to assign the ControlToValidate to be MID, which is the id of the input text. However, there isn't anything available in the ControlToValidate:
Then, I just type MID in it and run the program,
<form id="form1" runat="server">
<div>
<input type="text" id="MID" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="MID"></asp:RequiredFieldValidator>
<br />
</div>
</form>
It's been about 5 or 6 years since I last wrote an ASP.Net website, but I'm sure you can only use server side validators on server side input controls. Your form doesn't contain any server side input controls.
Your <input type="text" id="MID" />
should be an asp:TextBox
tag.
将runat="server"
添加到输入元素或使用ASP.NET TextBox控件( asp:TextBox
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.