Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RegularExpressionValidator Help

Posted on 2010-08-31
14
Medium Priority
?
342 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 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