Solved

RegularExpressionValidator Help

Posted on 2010-08-31
14
339 Views
Last Modified: 2013-11-05
I have a regularExpressionValidator that's failing on the text below and I don't know why.  I want my validator to allow all possible characters and force a minimum of 20 characters to be entered.

My validator is:

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20}" />

The text it's failing on is:

-           submission of pdf documents (merging, partial deletion of file etc) to clients

-           conversion to good quality pdf of quotations including hyperlink
0
Comment
Question by:scross1276
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 33568077
Hi,

Try


<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />

Yours would validate exactly 20 characters.

/peter

0
 

Author Comment

by:scross1276
ID: 33568107
I actually tried that after submitting this question and I still get my error message saying the justification needs to be longer.
0
 
LVL 5

Expert Comment

by:FredTang
ID: 33568156
ValidationExpression="\w{20,}"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:FredTang
ID: 33568252
please try :
ValidationExpression=".{20,}$"
0
 

Author Comment

by:scross1276
ID: 33568377
Still no luck.  I don't get it.  I tried both of your suggestions.

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification"
                        ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}$" />
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33568391
why you have used (.)?
0
 

Author Comment

by:scross1276
ID: 33568467
A period (.) is the regularExpressValidator option for all characters.  At least I believe so.
0
 
LVL 22

Expert Comment

by:pivar
ID: 33569974
The validator

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />           

works as intended for me in both asp.net 2.0 and 3.5

What kind of control is txtJustification?
0
 

Author Comment

by:scross1276
ID: 33570102
It's a standard textbox control.  <asp:textbox id="txtJustification" runat="Server" textMode="Multiline" />.
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33570109
i usually use [0-9a-zA-z/w] for this so asked
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33570165
can you share your aspx code
0
 

Author Comment

by:scross1276
ID: 33570300

<%@ Register TagPrefix="uc1" TagName="menu" Src="~/menu.ascx" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="generalSoftware.aspx.cs"
    Inherits="eForms.generalSoftware.generalSoftware" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>General Software Request</title>
    <link rel="stylesheet" type="text/css" href="../site.css" />
    <link rel="stylesheet" type="text/css" href="../print.css" />
</head>
<body>
    <form id="software" method="post" runat="server">
    <uc1:menu ID="Menu" runat="server"></uc1:menu>
    <div id="content">
        <br />
        <div class="header1">
            Information Technology</div>
        <div class="header2">
            General Software License Request</div>
        <br />
        <br />
        <asp:Table ID="tblRequestInfo" runat="server" CellSpacing="2" Width="750" BorderWidth="0">
            <asp:TableRow>
                <asp:TableCell Width="300px">
                    Date of Request:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Label ID="lblRequestDate" runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Requestor:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Label ID="lblRequestor" runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Employee Name Needing Software:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtName" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvName" ControlToValidate="txtName" Text="Name is required."
                        runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Department of Employee Needing Access:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtDepartment" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvDepartment" ControlToValidate="txtDepartment"
                        Text="Department is required." runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Approving Supervisor:<br /><br />
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlApprovingSupervisor" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvApprovingSupervisor" runat="server" ControlToValidate="ddlApprovingSupervisor"
                        ErrorMessage="This field is required." InitialValue="-1" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Business Unit of Employee Needing Access:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlBusinessUnit" runat="server" Width="325px">
                        <asp:ListItem Value=""></asp:ListItem>
                        <asp:ListItem>Corporate</asp:ListItem>
                        <asp:ListItem>Eastern Hemisphere</asp:ListItem>
                        <asp:ListItem>Manufacturing Supply Chain</asp:ListItem>
                        <asp:ListItem>Offshore Pipeline Solutions</asp:ListItem>
                        <asp:ListItem>Onshore Pipeline Solutions</asp:ListItem>
                        <asp:ListItem>Western Hemisphere</asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rfvBusinessUnit" runat="server" ControlToValidate="ddlBusinessUnit"
                        ErrorMessage="BU is required." InitialValue="" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
            Software being Requested:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlSoftware" runat="server" Width="325px" OnSelectedIndexChanged="ddlSoftware_SelectedIndexChanged" AutoPostBack="true" />
                    <br />
                    <asp:RequiredFieldValidator ID="rfvSoftware" runat="server" ControlToValidate="ddlSoftware"
                        ErrorMessage="You must select a software title." InitialValue="" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
            <asp:label ID="lblSoftwareNotListed" runat="server" Visible="false">Software Title &amp; Price if Not Listed Above:</asp:label>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtSoftwareNotListed" runat="server" Width="200px" Visible="false" />&nbsp;<asp:TextBox ID="txtPrice" runat="server" Width="50px" Visible="false" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>Business Justification for this Software:</asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtJustification" runat="server" TextMode="MultiLine" Rows="7" Columns="35"
                        MaxLength="500" /><br />
                    <asp:RequiredFieldValidator ID="rfvJustification" ControlToValidate="txtJustification"
                        Text="A business justification for this request is required." runat="server" /><br />
                    <asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification"
                        ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>Date Software is Needed:</asp:TableCell>
                <asp:TableCell>
                    <asp:Calendar ID="calDateNeeded" runat="server" BackColor="#585858" SelectedDayStyle-BackColor="#C90515"
                        SelectionMode="Day" TodayDayStyle-BackColor="#CFCFCF" TodayDayStyle-ForeColor="#000000"
                        CellPadding="0" CellSpacing="3" DayStyle-ForeColor="#FFFFFF" DayHeaderStyle-ForeColor="#CBCBCB"
                        DayNameFormat="FirstTwoLetters" Font-Size="8pt" TitleStyle-BackColor="#585858"
                        TitleStyle-Font-Bold="true" TitleStyle-ForeColor="#FFFFFF" OtherMonthDayStyle-ForeColor="#8E8E8E"
                        BorderColor="#000000" NextPrevStyle-ForeColor="#FFFFFF" OnSelectionChanged="calDateNeeded_SelectionChanged" />
                    <asp:TextBox ID="txtValidateCalendar" runat="server" CssClass="hideMe" />
                    <asp:RequiredFieldValidator ID="rfvCalendar" runat="server" ControlToValidate="txtValidateCalendar"
                        ErrorMessage="You must select a date." />
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
        <br />
        <div style="text-align: center; font-size: 10pt">
            By clicking the submit button below, you acknowledge the cost of the software you
            selected, which will initially be paid for by IT, then charged back to your department
            through allocation costs.</div>
        <br />
        <div style="text-align: center">
            <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" Text="Submit Request" runat="server"
                CssClass="btn" />
        </div>
        <br />
    </div>
    <asp:TextBox ID="txtRequestID" runat="server" Visible="false" />
    <asp:TextBox ID="txtRequestDetailsID" runat="server" Visible="false" />
    <asp:TextBox ID="txtApprovalID" runat="server" Visible="false" />
    <asp:TextBox ID="txtEmail" runat="server" Visible="false" />
    </form>
</body>
</html>

Open in new window

0
 
LVL 9

Accepted Solution

by:
puru1981 earned 500 total points
ID: 33570519
0
 

Author Closing Comment

by:scross1276
ID: 33570743
I've tried that before, with success.  The only problem is that my expression string gets very long to accomodate all of the characters users enter.  That's ok, at least it worked.  I'll go back to that.  Thank you for you sticking with this and helping me!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question