.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

RegularExpressionValidator - trailing blanks

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :.NET Framework
This is crazy ... ALL I want to do is check for 10 or less AlphaNumeric characters, and ignore any trailing whitespace in the text box I am checking ... I am using this: ValidationExpression   ="^[a-zA-Z0-9]{1,10}$". The validator, however, is returning 10 characters, plus 4 white spaces as an error (ie, "abcfdsitnr    "  ... which should not be an error).  Can anyone help? please? Thanks.

View Complete Post

More Related Resource Links

RegularExpressionValidator always fires

Hi friends,I am trying to use a RegularExpressionValidator for email ID text box. Everything works fine till I add an AJAX TextBoxWatermarkExtender for the same text box. I have given the WatermarkText="Email" for the text box. When I push the submit button, the RegularExpressionValidator fires and says Invalid Email ID. When I clear the same text box, no issues and the records are saved.I strongly suspect that the RegularExpressionValidator is taking the text of the watermark, ie "Email" as an invalid email ID. To test this I gave the text as "someone@website.com" for the  TextBoxWatermarkExtender and it did not fire the RegularExpressionValidator.The Email ID field in my page is not mandatory but should have a valid email ID. Have any one faced same issue and does any one have a solution to this?I am pasting the code below:<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" ToolTip="Enter Email" CssClass="input" ValidationGroup="register" > </asp:TextBox> <cc1:TextBoxWatermarkExtender ID="txtEmail_TextBoxWatermarkExtender" runat="server" Enabled="True" TargetCo

very simple asp:RegularExpressionValidator for Email not working

My implementation is simple. I have a public static variable in a class called EmailHelper containing my regular expression as follows:namespace Base.Core.Utilities { public static class EmailHelper { public const string EMAIL_REGEX = @"^([a-zA-Z0-9]+([\.+_-][a-zA-Z0-9]+)*)@(([a-zA-Z0-9]+((\.|[-]{1,2})[a-zA-Z0-9]+)*)\.[a-zA-Z]{2,6})$"; } } I then have the following web controls on my page:<asp:Panel ID="pnlChangeEmail" runat="server" DefaultButton="btnChangeEmail"> <asp:Label ID="lblChangeEmail" AssociatedControlID="txtEmail" runat="server">New email:</asp:Label> <asp:TextBox ID="txtEmail" runat="server" CssClass="textfield"></asp:TextBox> <asp:LinkButton ID="btnChangeEmail" OnClick="Change_Email" runat="server" ValidationGroup="ChangeEmail" CssClass="btn"> <strong><asp:Literal runat="server" ID="litSubmit" Text='<%$ Resources: GlobalResource, SUBMIT %>' /></strong> </asp:LinkButton> <asp:RequiredFieldValidato

RegularExpressionValidator regarding on the radiobutton

I have RadioButton1, RadioButton2, TextBox1, TextBox2 and Button1This code for TextBox1:<asp:RegularExpressionValidator ID="RegularExpressionValidator3" ValidationExpression="^[0-9]{3}$" runat="server" ControlToValidate="TextBox1"  ErrorMessage="Vnesite!"                 ValidationGroup="ErrormessageValidationGroup"  Display="Dynamic"> <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/warning.png" ImageAlign="TextTop" /></asp:RegularExpressionValidator>This code for TextBox2: <asp:RegularExpressionValidator ID="RegularExpressionValidator3" ValidationExpression="^[0-9]{3}$" runat="server" ControlToValidate="TextBox2"  ErrorMessage="Vnesite!"                  ValidationGroup="ErrormessageValidationGroup"  Display="Dynamic"> <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/warning.png" ImageAlign="TextTop" /></asp:RegularExpressionValidator>I want to "Button1" writes:If RadioButton1 = True to use the first code ... ControlToValidate=

RegularExpressionValidator and the new AsyncFileUpload

 Hi,I try to valide the new AJAX AsyncFileUpload control but it seems not to work : Control 'AsyncFileUpload1' referenced by the ControlToValidate property of 'REV1' cannot be validated.<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" Width="400px"                     ThrobberID="throbber" />                <asp:Label ID="throbber" Style="display: none" runat="server"><img alt="loading" src="images/upload.gif" /></asp:Label><asp:RegularExpressionValidator                    ID="REV1" runat="server" ErrorMessage=" File invalid"                    ControlToValidate="AsyncFileUpload1" ValidationExpression="(.*\.([gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP]|[pP][nN][gG])$)"                    Display="Dynamic" Text="

Problems with RegularExpressionValidator



I have a simple test page with the following:

    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
        ErrorMessage="MELLOM 1 og 200" 
    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="531px"></asp:TextBox>

As you probably see, I'm trying to validate if the field contains BETWEEN 1 and 200 "anythings". The problem is that it triggers correctly if there are more than 20 "anythings" in the text box, but not if there are zero :S

Anyone see what the problem might be?


Is RegularExpressionValidator.IsValid ok to use server side?


I am using regular expression validators.  I know that I have to validate client side and server side. 

Is it ok to use RegularExpressionValidator.IsValid on the server side to see if the field is valid?  Do I have to use RegularExpressionValidator.Validate before RegularExpressionValidator.IsValid is set?

Filling in the blanks



I have 1 fact with 2 dimensions which look like this :

  1 2 3 4 5 Total
1 10   &

Field blanks out as form is being filled in


I have an InfoPath form hosted in SharePoint that has some peculiar behavior. This form was previously hosted in forms services on SharePoint 2007, and worked for several years without problems, but we recently upgraded to 2010, and now I have this issue. The form is used to request that a design project be initiated, and is fairly large - about 100k empty.

There are two different fields in the form that seemingly at random get blanked out as the form is being completed. One is a check box, which determines if a certain workflow step will be performed (create a customer quote), and the other is a rich text field used to enter additional project information. There are no rules that point at the check box to set it's value, but it does have some rules tied to it to set another field if it is selected. And the rich text box has a rule to concatinate a file number to the existing text if a certain button is pushed. That is all. There are no rules in place to clear these fields. In each instance there was additional activity occuring before the form was submitted (other fields were being selected, documents were being attached, dates being entered, etc.).

I managed to duplicate the clearing of the rich text box in troubleshooting, but have not actually seen the check box get cleared. I repeated my steps to get the rich text box to clear, and the second tim

CHAR trailing spaces 2005 vs 2008


We switched from SQL Server 2005 to SQL Server 2008 and came across  an issue with trailing spaces being preserved when we select CHAR value.
For example, I have a CHAR(30) column with value 'abcd'. When i run application with SQL2005, the value that comes back is 'abcd'. In SQL2008 it's 'abcd                                '.

ANSI_PADDING is OFF on both DBs.
Any other settings that force SQL server trim the trailing spaces? 

I read about REPLACE change, it says that in SQL Server 2008, trailing spaces specified in the first input parameter are always preserved. Is this change applicable all across SQL2008?

Any pointers?
Thank you.

RegularExpressionValidator for min num of characters


using vb.net/asp.net 2005.

I have a regularExpressionValidator and I need to make a simple regular expression that will force the user to enter 7 characters or more in a textbox.

Does anyone know the ValidationExpression for this?


but its not working. thanks


RegularExpressionValidator fire with postback



After several tests, I made the conclusion that my RegularExpressionValidator fires with the postback.

Situation: I have an upload control, the input is validated after the user hits the upload button, after the postback it returns an invalid status message because there is no input in the upload control anymore (which I also don't want... the user has to select a file).

How can I prevent this? Now, the error message is misleading.


How do I filter a SharePoint list on blanks?

I have a large SharePoint list and want to create a view the shows only rows where a particular column is blank.  I know there are some special values like [Today] and [Me].  Is there one for [Blank] or [Null]?  How can this be done?

Remove Trailing Whitespace Conditionally


I have code to remove trailing whitespace that I want to adapt to ONLY operate on lines in a file that contain other text i.e. I don't want to remove blank lines.  My Regex expression is \s+$ (I know, very simple).  How can I adapt this to ignore completely blank lines?

C#, Visual Studio 2005.

Badger 2196

How do I avoid trailing bashslashs when importing strings from sybase SQLAnywhere into SQL2008?



we had that issue in SQL2005 and Sybase5 before and have never been able to solve it. Now that we upgraded to Sybase10 and SQLServer2008, I hoped we didn't have to trim any single DT_STR-Field we get from Sybase any longer. But it's still the same. I tried both, the SQLAnywhere ODBC - Driver and the OleDB-Driver. It doesn't matter.
Does anybody know a way to get the DT_STR - Fields from Sybase to SQLServer without having to derive a column and trim the fields?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend