简体   繁体   中英

asp.net validation message position

I have a registration form where each field have a validation message beside it, and the problem is there are some fields that has more than one validation message so their position will be a little bit away from its field like this:

在此处输入图片说明

so when I test the validation the (email required) message will be on the top of the field and the (wrong email form) message will be below. and my question is how can I put the three messages in the same position in the right of the field ?

You can use a "Validation Summary" Set your validators to Display=None

and then add the validation summary in the position you would like to display the validators messages:

<asp:ValidationSummary id="valSummary" runat="server"
    HeaderText="Review your input, the following errors occurred:"
     ShowSummary="true" DisplayMode="List" />

For more references check here .

在此处输入图片说明

i have also found that only one error will show up at a time . so it only looks bad in design view. when running, if someone does not enter an address, only the 'required' error will show; if the email is taken, obviously something has been entered, so only the 'taken' error will show; if it's the wrong format, only the 'wrong format' error will show.

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