Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET validators alignment issue

I am developing contactus webpage which have a input field called Email. It is validated against a required field validator and regular expression validator with appropriate messages.

Required: Enter Email Regular Expression: Invalid Email

I am setting these two as given below:

<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                                    <font color="#FF0000">*</font>
                                    <asp:RequiredFieldValidator ID="rfvemail" CssClass="error_text" ControlToValidate="txtEmail"
                                        runat="server" ErrorMessage="Enter email address."></asp:RequiredFieldValidator>
                                         <asp:RegularExpressionValidator ID="revemail" runat="server" ControlToValidate="txtEmail"
                                            ErrorMessage="Invalid Email" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>

My problem is both Enter Email and Invalid Email is occupying its own space. For Ex: If I leave email as empty space and press submit, Enter Email is displaying right next to it. If I enter invalid email(xxx), Enter Email is off but taking the space, Invalid Email message is displayed after these space taken by 'Enter Email' before.

Is there any way to remove this space??

Mahesh

like image 346
Mahesh Avatar asked May 11 '10 13:05

Mahesh


People also ask

Which validator shows all the error messages from the validators in one specific place on the page?

The ValidationSummary class is used to summarize the error messages from all validators on a Web page in a single location. You can summarize the error messages from a group of validators on a Web page by assigning the ValidationSummary control to a validation group by setting the ValidationGroup property.

Which validator control is used for validating the data based on specific patterns?

Using RegularExpressionValidator server control, you can check a user's input based on a pattern that you define using a regular expression. It is used to validate complex expressions. These expressions can be phone number, email address, zip code and many more.

Where do ASP.NET validation controls validate data?

Where do the ASP.NET validation controls validate data, on the Client or on the Web Server? ASP.NET validation controls validate data on the client as well as web server. If we need to validate data on client side itself, we have to set a property to controls to execute at the client side.

Which side validation routine should be written in any dotnet language?

The server side validation routine should be written in any . Net language, like C# or VB.Net.


2 Answers

Set Display = "Dynamic" on it.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.display%28v=VS.100%29.aspx

like image 103
David Avatar answered Sep 19 '22 12:09

David


Use Diplay = "Dynamic"

The display behavior for the validation control. Legal values are:

  • None (the control is not displayed. Used to show the error message only in the ValidationSummary control)
  • Static (the control displays an error message if validation fails. Space is reserved on the page for the message even if the input passes validation.
  • Dynamic (the control displays an error message if validation fails. Space is not reserved on the page for the message if the input passes validation
like image 29
Claudio Redi Avatar answered Sep 19 '22 12:09

Claudio Redi