Reputation: 270
I'm trying to make a registration form for a ASP.NET project, it has to include a "Is Required" test for each field. Anyone have any good resources on this?
Upvotes: 0
Views: 17
Reputation: 4318
If this is WebForms you can use RequiredFieldValidator. Here is a simple example that would valid a text box named "txtName":
<asp:RequiredFieldValidator runat="server"
ControlToValidate="txtName"
ErrorMessage="User ID is required."> *
</asp:RequiredFieldValidator>
Here is an MSDN article that talks about exactly what you want and gives examples of other validators (again, assuming this is WebForms):
https://msdn.microsoft.com/en-us/library/ms972961.aspx
And a code project article with more examples and info:
http://www.codeproject.com/Articles/334310/Understanding-ASP-NET-Validation-Techniques
Upvotes: 1