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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Validation expression problem

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

Ok, im in the process of updating our member registration form. We have always used this reg. exp. for emails and it works OK:


But I wanted to update it and found this one posted on some forums and on some major sites:


Like this:

<asp:RegularExpressionValidator ID="valEmailCorrect" ForeColor="" runat="server" Display="Dynamic" ControlToValidate="tbemail"  ValidationExpression="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"></asp:RegularExpressionValidator>

This expression doesent work at all for me, cant enter any mail at all, all mails are rejected?!  Does anyone knows why?

View Complete Post

More Related Resource Links

validation problem

hii design a register users form for my wesite.i using validation controls in my form, for instance(requiredfield validator and compare validator)i make validation group for my validation controls and register buttonvalidation group is equal for all my validation controls and button. when is empty one of textboxes and i click on register button first run button function then enable validationsthis is my problemthe validations must enable before run the button functionthis is my html codes:<table class="format">                                <tr>                                    <td colspan="2">                                        <asp:Label ID="Label10" runat="server" Font-Bold="True" Font-Names="Tahoma"             &n

Date validation problem modelstate.isvalid is false

In my view i am formatting the date as follows<%= Html.TextBox("MemoDate", string.Format("{0:dd/MM/yyyy hh:mm}", DateTime.Now),new{ @readonly = true })%> In controller ModelState.IsValid become false as my current culture culture {en-US} doesn't match with the format of date.

Regular Expression, Email Validation, Consective dots name part

Hi All Can you please help me to modify this regex to validate consecutive dots in the name part (before @) of the email string.  For example, i want to disqualify an email string like (george...antony@gmail.com).  But an email string with single dots in the name part should be allowed (george.antony@gmail.com).   This regex is validating the consecutive dots after the @ sign (domain part) .    All other validation with this regex is as expected.   ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$     Thanks in advance george

SSRS 2008 R2 Problem understanding View State Validation steps

Hi, Sorry, but I have some problem understanding this steps. Please help me to understand this.  Pasted from http://technet.microsoft.com/en-us/library/cc281307.aspx?lc=1033 How to Configure View State Validation To run a scale-out deployment on an NLB cluster, you must configure view state validation so that users can view interactive HTML reports. You must do this for the report server and for Report Manager. View state validation is controlled by the ASP.NET. By default, view state validation is enabled and uses the identity of the Web service to perform the validation. However, in an NLB cluster scenario, there are multiple service instances and web service identities that run on different computers. Because the service identity varies for each node, you cannot rely on a single process identity to perform the validation. To work around this issue, you can generate an arbitrary validation key to support view state validation, and then manually configure each report server node to use the same key. You can use any randomly generated hexadecimal sequence. The validation algorithm (such as SHA1) determines how long the hexadecimal sequence must be. Generate a validation key and decryption key by using the autogenerate functionality provided by the .NET Framework. (Well, how to generate Validation key using .Net Framework?) In the end, you must have a singl

validation problem

hii design a user register form for my website.in this form i using validation control.for instance : required field validator and compare validator.but i have problem with this controlsi make a Validationgroup for validation with register button.validationgroup is equal for all controls(validations and button).when i dont fill textboxes and i click on the button first run the button function then run validations.where is my problem?this is my html codes:<table class="format">                                <tr>                                    <td colspan="2">                                        <asp:Label ID="Label10" runat="server" Font-Bold="True" Font-Names="Tahoma"                   &

EMail Validation Problem

Hai friends,         I have to do  validation for E-Mail using JAVA Script,  The Following code was not working, function Valid() { if (ValidateEmail("<%= textBox.ClientID %>") ) { alert ("Correct"); return true ; } else { alert ("Not Correct"); } } function ValidateEmail(email) { var EmaiAddress=document.getElementById(email); var RegExEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/; if(!RegExEmail .test (EmaiAddress )) { return false ; } else { return true ; } } <asp:button id="button" runat="server" OnClientClieck="validateEmail() " >but,This code was working, function ValidateEmail() { var EmaiAddress=document.getElementById("textbox").value; var RegExEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/; if(!RegExEmail .test (EmaiAddress )) { alert("Not Correct"); } else { alert("Not Correct"); } } <asp:button id="button" runat="server" OnClientClieck="validateEmail() " >   Please Fix the solution.  

regular expression problem


i have to check if an input string is valid based on the given regular expression.. this is the regular expression.

(a(bb+aaa+((ab)*bb+(aba)*aa)(a+b)*) + (b(aa+bbb+((ba)*aa+(bab)*bb)(a+b)*)

+ is an OR

* is a LOOP, it is optional, it may be done as many as a user wants.

i've tried many ways to solve the problem that my professor gave me but my knowledge isn't that enough to solve this problem.. 

any help would be much appreciated.. :D thanks!

regarding validation of user information problem


Iam new to asp.net. in my web page iam validating user information such as fname,lname,sex,add and also login (to register to website)information emailid and password . here iwant to check email adrress (availblity) and tht iam doing it fine. but when iam validating all the textbox,which are there before emailid  something like this




login details

emailid:   check (buttonto check email availiblity)


retype password:


iam using validation controls for all the text boxes , when iam using my tab to enter the values it w,l give me alll error messege until i fill it. and when i reach email textbox  and check availblity then i cant check untill i fill the password and retype password texboxes..i can only check the email availblity only when al the fields are valid . but i want to valid the emailid before i could enter password and retype password ? how to do this  pls help me out..

Problem with date validation.


I have the following code:

protected bool ValidGebdat()
    Regex LongDate = new Regex("^([1-9]|0[1-9]|1[012])[- /.]([1-9]|0[1-9]|[12][0-                   9]|3[01])[- /.][0-9]{4}$");

    string gebDat = GebdatTB.Text;

    string s = gebDat.Trim();

            if (LongDate.Match(s).Success)
                   return true;
                  return false;

Why do I get a return false when I insert "27-02-1970"?

Validation Summary with regular Expression validator


I have a page that im using Validation Summary on. I have 5 out of 8 fields that im validating. All 5 have required validators and 1 of the 5 also has regularexpressionvalidator with it.

When the page load and i click the submit, all the fields show my red * next to them and the individual messages down in the summary. Thats find, but im having issues with checking the field with the regex validation when you submit the form again. At the moment, i had added a if condition on the button event and it is preventing the form from submitting and the field is showing the red * next to it, but my message from the regex validator does not display in the summary. Actually the summary doesnt even show up. The regex validator works when you tab out of the field by placing the red *, but the actual error message doesnt display in the summary, so you wouldnt know why there is an issue.


I have the following as a test, def isnt correct, but was trying to show the summary with the value from my regex validator:

        protected void btnInfo_Click(object sender, EventArgs e)
            if (!Page.IsValid)
                vsSumm.ShowSummary = true;

Javascript Regular Expression Problem


Hi all,

I have the problem about using regular expression.

At first, I found currency textbox script at http://blog.developers.ie/cgreen/archive/2009/04/24/currency-field-with-javascript.aspx.

Thank you Mr. Christopher Green for first solution. Smile

It is very cool script for inputable only decimal number.


After that, I had more requirement about "currency textbox can inputable '-' sign".

Ex. It can inputable '-23.89'.

I try apply regular expression in below function

function fnCurrencyOnly(o) {
            var sValue = o.value;
            var sKey = String.fromCharCode(window.event.keyCode);
            if (document.selection.createRange().text == sValue) {
                sValue = sKey;
            } else {

Join Expression Not SHi All, I use Access 2007, and I have the following SQL problem: I have two t

Hi All,

I use Access 2007, and I have the following SQL problem:

I have two tables TransformerTypePeriodBOMProducts and TransformerTypePeriodProducts. The first table has 4 fields: TransformerTypeID, OutputProductID, PeriodID and BOM, while the second has the following 4 fields: TransformerTypeID, OutputProductID,PeriodID and AssemblyCapacity. So as you can see, there are 3 fields (TransformerTypeID, OutputProductID and PeriodID) that are in both tables.

I need to delete all records in the first table that have the field AssemblyCapacity in the second table equal to 0 (and of course have similar TransformerTypeID, OutputProductID and PeriodID fields).

I tried many trials, the last I got was:

SELECT TransformerTypeAssemblyPeriodBOMProducts.*
FROM ((TransformerTypeAssemblyPeriodBOMProducts INNER JOIN TransformerTypeAssemblyPeriodProducts ON TransformerTypeAssemblyPeriodBOMProducts.TransformerTypeID=TransformerTypeAssemb
lyPeriodProducts.TransformerTypeID) INNER JOIN TransformerTypeAssemblyPeriodProducts ON TransformerTypeAssemblyPeriodBOMProducts.OutputProductID=TransformerTypeAssembly
PeriodProducts.OutputProductID) INNER JOIN TransformerTypeAssemblyPeriodProducts ON TransformerTypeAssemblyPeriodBOMProducts .PeriodID=TransformerTypeAssemblyPeriodProducts.PeriodID
DELETE * FROM TransformerTypeAssemblyPeriodB

Problem with Jquery windows modal + Validation Summary


Hi all, 

I have a jquery windows modal with some textboxes and a OK button, i have placed some field validators to 
respective textboxes with ValidationGroup. 

When the windows modal opens, the required field validator are  working when clicking on 

OK button but i cannot to visualize the error summary. 

how can i do to visualize the summary? 

thx in advance!

how does the string validation work for this regular expression?

 _strInt = value.ToString();
Regex objPattern = new Regex("[^ a-zA-Z]" ); if (objPattern.IsMatch(_strInt)) { return   new ValidationResult(true , null );
   } else return new ValidationResult(false , "Value must contain only alphabets" ); } }

if i pass a valid expression as "abc" .. its Failing .
Can some1 explaing how it's failing .

Problem with future date validation using CompareValidator


Realy simple aspx page:

<asp:TextBox ID="txtExpireDate" runat="server" Width="78px" MaxLength="10" ></asp:TextBox>


Regular expression validation



I'm using a regular expression validator on a number forms but I can't get this one (the simplest) to work

The regex pattern is ^(?!Search for) which should stop a user pressing the submit button before valid input is entered.  The result however is that it stops every unput.

Anyone help?

The dreaded Checkbox Empty Validation problem


I've seen zillions of postings on how to deal with the issue where you need to validate a Checkbox to ensure the user has checked it "true" or "on", or "checked".  Useful for making them confirm they have read and/or agree to something.

It seems unfortunate that the base controls don't handle this, and many others agree with me...nonetheless...

I have tried to implement a hybrid of some of these solutions.  Anyway, here's what I've put together, and I am not skilled enough to know why this does not work.  It doesn't generate any errors, and when I look at the rendered HTML via "view page source", there is nothing obvious that I see...for example, all the controls appear to be there and seem to render the same as any of the static HTML controls that are also on the page.

Anyone able to enlighten me?  Thanks in advance:

1.  In a utility library, I create a class that inherits from the CheckBox class, so that I can dynamically create it in code.  (I don't want to bother creating a UserControl for this because it seems like overkill to implement a single missing (my opinion) property.  I lifed the equivalent of this code from other forum posts.

namespace CommonClasses
    //extend the standar
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