简体   繁体   中英

Why do only the first two validators trigger on my ASP.NET C# website?

I have a form that asks a user for their first name, last name, phone number, ID number, username, and check boxes to choose either faculty or student in that order. The first two text boxes have two validators each, a regular expression: ^[a-zA-Z- ]*$ and required field validator. After that I created some custom validators as in addition to the text box for phone number, ID number, and username I have a "Don't know?" checkbox in case they forgot. So it validates to make sure they either typed in something and if not to make sure the check box is checked. Now, if I fire up the site and simply click the confirm button only the first two fields trigger their validation, that is the first and last name fields. Now, if I put in a first and last name and click confirm button again the rest of the validators trigger as normal. How can I get them to all trigger at once? Thanks.

Your custom validator logic may be implemented only in server side. You may have to provide the validation logic at client side by writing a javascript method and specifying it in ClientValidationFunction property. The link also provides an example on how to implement it in the client side.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM